Link Search Menu Expand Document

Date constructor

Explanation Initialize the Date object.

If no arguments are taken, it will be initialized with the current date and time.

When one argument is specified, if the argument is a character string representing date / time, the same interpretation as the parse method is performed, otherwise the date and time are initialized as milliseconds representing the elapsed time from UTC reference time increase.
See parse method for string format

If two or more arguments are specified, up to seven will be initialized as year, month, day, hour, minute, second, and millisecond (actually invalid).All omitted arguments will be 0.

Creating a Date object without a constructor call will create a Date object with an invalid date and time without being initialized.
Call format var d = new Date( )
var d = new Date(value)
var d = new Date(year, month, date [, hours [, minute [, sec [, ms ] ] ] ])
Return value Date object
Arguments Object value An object that represents a date string or elapsed time
integer year Specify the year numerically
integer month Specify the month number with January as 0
integer date Specify the day numerically
integer hours Specify the hour numerically
integer minute Specify the minute numerically
integer sec Specify the seconds numerically
integer ms Ignored
Exception None
Example of use
var d1 = new Date ();
var d2 = new Date (1964, 8, 10);
var d3 = new Date ("2002/01/02 12:34:56");
var d4 = new Date (1022889600000);
Related item parse method