Name
Date: manipulate dates and times — ECMAScript v1: Object → Date
Constructor
new Date( ) new Date(milliseconds
) new Date(datestring
) new Date(year
,month
,day
,hours
,minutes
,seconds
,ms
)
With no arguments, the Date(
)
constructor creates a Date object set to the current date and time. When one numeric
argument is passed, it is taken as the internal numeric
representation of the date in milliseconds, as returned by the
getTime( )
method. When one
string argument is passed, it is a string representation of a date,
in the format accepted by the Date.parse(
)
method. Otherwise, the constructor is passed between two
and seven numeric arguments that specify the individual fields of
the date and time. All but the first two arguments—the year and
month fields—are optional. Note that these date and time fields are
specified using local time, not Coordinated Universal Time (UTC) (which is
similar to Greenwich Mean Time [GMT]). See the static Date.UTC( )
method for an
alternative.
Date( )
may also be called
as a function, without the new
operator. When invoked in this way, Date(
)
ignores any arguments passed to it and returns a string
representation of the current date and time.
Arguments
-
milliseconds
The number of milliseconds between the desired date and midnight on January 1, 1970 (UTC). For example, passing the argument 5000 creates a date that represents five seconds past midnight on 1/1/70.
-
datestring
A single argument that specifies the date and, optionally, the time as a string. ...
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.