Home > Article > Web Front-end > JavaScript method Date() that returns the date and time of the day
Definition and Usage
The Date() method returns the date and time of the current day.
Syntax
Date()
Example
In this example, we will output today’s date and time:
<script type="text/javascript"> document.write(Date()) </script>
Output:
Sat Nov 04 2017 13:57:47 GMT+0800 (中国标准时间)
1. Introduction
1.1 Description
DateObject is an object for operating date and time. The Date object can only operate on date and time through methods.
1.2 Attributes
None; the Date object can only operate on date and time through methods.
2. Constructor
2.1 new Date(): Return the current local date and time
Parameters: None
Return value:
{Date} Returns a Date object representing the local date and time.
Example:
var dt = new Date(); console.log(dt); // => 返回一个表示本地日期和时间的Date对象
The above is the detailed content of JavaScript method Date() that returns the date and time of the day. For more information, please follow other related articles on the PHP Chinese website!