JavaScript Date 對象參考手冊
Date 對象
Date 對象用于處理日期和時間。
創(chuàng)建 Date 對象的語法:
var myDate=new Date()
注釋:Date 對象會自動把當前日期和時間保存為其初始值。
Date 對象屬性
FF: Firefox, IE: Internet Explorer
(1) constructor 屬性返回對創(chuàng)建此對象的 Date 函數(shù)的引用。
語法
object.constructor
實例
在本例中,我們將展示如何使用 constructor 屬性:
1<script type="text/javascript">
2
3var test=new Date();
4
5if (test.constructor==Array)
6{
7document.write("This is an Array");
8}
9if (test.constructor==Boolean)
10{
11document.write("This is a Boolean");
12}
13if (test.constructor==Date)
14{
15document.write("This is a Date");
16}
17if (test.constructor==String)
18{
19document.write("This is a String");
20}
21
22</script>
輸出:
This is a Date
(2)
posted @ 2010-03-12 17:27 housen 閱讀(88) | 評論 (0) | 編輯 收藏