什么是JavaScript中的日期对象?

Date对象是JavaScript语言内置的数据类型。使用新的Date()创建Date对象,如下所示-

new Date( )

new Date(milliseconds)

new Date(datestring)

new Date(year,month,date[,hour,minute,second,millisecond ])

示例

您可以尝试运行以下代码以在JavaScript中实现Date对象-

<html>

   <head>

      <title>JavaScript Dates</title>

   </head>

   <body>

      <script>

         var date = new Date();

         document.write("dt.constructor is : " + date.constructor);

      </script>

   </body>

</html>

输出结果

dt.constructor is : function Date() { [native code] }

以上是 什么是JavaScript中的日期对象? 的全部内容, 来源链接: utcz.com/z/326783.html

回到顶部