Enables basic storage and retrieval of dates and times.
dateObj = new Date() dateObj = new Date(dateVal) dateObj = new Date(year, month, date[, hours[, minutes[, seconds[,ms]]]])
A Date object contains a number representing a particular instant in time to within a millisecond. If the value of an argument is greater than its range or is a negative number, other stored values are modified accordingly. For example, if you specify 150 seconds, JavaScript redefines that number as two minutes and 30 seconds.
If the number is NaN, the object does not represent a specific instant of time. If you pass no parameters to the Date object, it is initialized to the current time (UTC). A value must be given to the object before you can use it.
The range of dates that can be represented in a Date object is approximately 285,616 years on either side of January 1, 1970.
See Date and Time Calculations (JavaScript) for more information about how to use the Date object and related methods.
The following table lists functions of the Date Object.
Functions | Description |
|---|---|
Returns the number of milliseconds between January 1, 1970, and the current date and time. | |
Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. | |
Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the supplied date. |
The following table lists methods of the Date Object.
Method | Description |
|---|---|
Returns the day-of-the-month value using local time. | |
Returns the day-of-the-week value using local time. | |
Returns the year value using local time. | |
Returns the hours value using local time. | |
Returns the milliseconds value using local time. | |
Returns the minutes value using local time. | |
Returns the month value using local time. | |
Returns seconds value using local time. | |
Returns the time value in a Date Object as the number of milliseconds since midnight January 1, 1970. | |
Returns the difference in minutes between the time on the host computer and Universal Coordinated Time (UTC). | |
Returns the day-of-the-month value using UTC. | |
Returns the day-of-the-week value using UTC. | |
Returns the year value using UTC. | |
Returns the hours value using UTC. | |
Returns the milliseconds value using UTC. | |
Returns the minutes value using UTC. | |
Returns the month value using UTC. | |
Returns the seconds value using UTC. | |
Returns the VT_DATE value in a Date object. | |
Returns the year value . | |
Returns a Boolean value that indicates whether an object has a property with the specified name. | |
Returns a Boolean value that indicates whether an object exists in another object's prototype chain. | |
Returns a Boolean value that indicates whether a specified property is part of an object and whether it is enumerable. | |
Sets the numeric day of the month using local time. | |
Sets the year value using local time. | |
Sets the hours value using local time. | |
Sets the milliseconds value using local time. | |
Sets the minutes value using local time. | |
Sets the month value using local time. | |
Sets the seconds value using local time. | |
Sets the date and time value in the Date object. | |
Sets the numeric day of the month using UTC. | |
Sets the year value using UTC. | |
Sets the hours value using UTC. | |
Sets the milliseconds value using UTC. | |
Sets the minutes value using UTC. | |
Sets the month value using UTC. | |
Sets the seconds value using UTC. | |
Sets the year value using local time. | |
Returns a date as a string value. | |
Returns a date converted to a string using Greenwich Mean Time (GMT). | |
Returns a date as a string value in ISO format. | |
Used to transform data of an object type before the JSON serialization. | |
Returns a date as a string value appropriate to the host environment's current locale. | |
Returns an object converted to a string using the current locale. | |
Returns a time as a string value appropriate to the host environment's current locale. | |
Returns a string representation of an object. | |
Returns a time as a string value. | |
Returns a date converted to a string using UTC. | |
Returns the primitive value of the specified object. |