Name
Date — manipulate dates and times
Inherits from
Object → Date
Constructor
newDate()newDate(milliseconds)newDate(datestring)newDate(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
millisecondsThe 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.
datestringA single argument that specifies the date and, optionally, the time as a string. The string should ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access