2010年3月12日

JavaScript Date 对象参考手册

Date 对象

Date 对象用于处理日期和时间。

创建 Date 对象的语法:

var myDate=new Date()

注释:Date 对象会自动把当前日期和时间保存为其初始值。


Date 对象属性

FF: Firefox, IE: Internet Explorer

    (1)    constructor 属性返回对创建此对象的 Date 函数的引用。  

            语法

        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 阅读(80) | 评论 (0)编辑 收藏

仅列出标题  
<2024年6月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

导航

统计

常用链接

留言簿

随笔档案

搜索

最新评论