Date
Methods
Getter
dateObj.getDate()
- Returns the day of the month (1-31) for the specified date according to local time.
dateObj.getDay()
- Returns the day of the week (0-6) for the specified date according to local time.
dateObj.getFullYear()
- Returns the year (4 digits for 4-digit years) of the specified date according to local time.
dateObj.getHours()
- Returns the hour (0-23) in the specified date according to local time.
dateObj.getMilliseconds()
- Returns the milliseconds (0-999) in the specified date according to local time.
dateObj.getMinutes()
- Returns the minutes (0-59) in the specified date according to local time.
dateObj.getMonth()
- Returns the month (0-11) in the specified date according to local time.
dateObj.getSeconds()
- Returns the seconds (0-59) in the specified date according to local time.
dateObj.getTime()
- Returns the numeric value of the specified date as the number of milliseconds since January 1, 1970, 00:00:00 UTC (negative for prior times).
dateObj.getTimezoneOffset()
- Returns the time-zone offset in minutes for the current locale.
dateObj.getUTCDate()
- Returns the day (date) of the month (1-31) in the specified date according to universal time.
dateObj.getUTCDay()
- Returns the day of the week (0-6) in the specified date according to universal time.
dateObj.getUTCFullYear()
- Returns the year (4 digits for 4-digit years) in the specified date according to universal time.
dateObj.getUTCHours()
- Returns the hours (0-23) in the specified date according to universal time.
dateObj.getUTCMilliseconds()
- Returns the milliseconds (0-999) in the specified date according to universal time.
dateObj.getUTCMinutes()
- Returns the minutes (0-59) in the specified date according to universal time.
dateObj.getUTCMonth()
- Returns the month (0-11) in the specified date according to universal time.
dateObj.getUTCSeconds()
- Returns the seconds (0-59) in the specified date according to universal time.
Setter
dateObj.setDate()
- Sets the day of the month for a specified date according to local time.
dateObj.setFullYear()
- Sets the full year (e.g. 4 digits for 4-digit years) for a specified date according to local time.
dateObj.setHours()
- Sets the hours for a specified date according to local time.
dateObj.setMilliseconds()
- Sets the milliseconds for a specified date according to local time.
dateObj.setMinutes()
- Sets the minutes for a specified date according to local time.
dateObj.setMonth()
- Sets the month for a specified date according to local time.
dateObj.setSeconds()
- Sets the seconds for a specified date according to local time.
dateObj.setTime()
- Sets the
Date
object to the time represented by a number of milliseconds since January 1, 1970, 00:00:00 UTC, allowing for negative numbers for times prior.
dateObj.setUTCDate()
- Sets the day of the month for a specified date according to universal time.
dateObj.setUTCFullYear()
- Sets the full year (e.g. 4 digits for 4-digit years) for a specified date according to universal time.
dateObj.setUTCHours()
- Sets the hour for a specified date according to universal time.
dateObj.setUTCMilliseconds()
- Sets the milliseconds for a specified date according to universal time.
dateObj.setUTCMinutes()
- Sets the minutes for a specified date according to universal time.
dateObj.setUTCMonth()
- Sets the month for a specified date according to universal time.
dateObj.setUTCSeconds()
- Sets the seconds for a specified date according to universal time.
Conversion getter
dateObj.toDateString()
- Returns the "date" portion of the
Date
as a human-readable string.
dateObj.toISOString()
- Converts a date to a string following the ISO 8601 Extended Format.
dateObj.toJSON()
- Returns a string representing the
Date
using toISOString()
. Intended for use by JSON.stringify()
.
dateObj.toLocaleDateString()
- Returns a string with a locality sensitive representation of the date portion of this date based on system settings.
dateObj.toLocaleFormat()
- Converts a date to a string, using a format string.
dateObj.toLocaleString()
- Returns a string with a locality sensitive representation of this date. Overrides the
Object.prototype.toLocaleString()
method.
dateObj.toLocaleTimeString()
- Returns a string with a locality sensitive representation of the time portion of this date based on system settings.
dateObj.toSource()
- Returns a string representing the source for an equivalent
Date
object; you can use this value to create a new object. Overrides the Object.prototype.toSource()
method.
dateObj.toString()
- Returns a string representing the specified
Date
object. Overrides the Object.prototype.toString()
method.
dateObj.toTimeString()
- Returns the "time" portion of the
Date
as a human-readable string.
dateObj.toUTCString()
- Converts a date to a string using the UTC timezone.
dateObj.valueOf()
- Returns the primitive value of a
Date
object. Overrides the Object.prototype.valueOf()
method.
Created by Mozilla Contributors and licensed under
CC-BY-SA 2.5