Formats the date part as text, without the time, in the local time zone.
Example: 15 January 2024 at 14:30 -> 'Mon Jan 15 2024'
The date
The date as text such as 'Mon Jan 15 2024'
Formats the date and time in the ISO 8601 form used for data exchange, always in UTC.
Example: 15 January 2024 at 14:30 -> '2024-01-15T14:30:45.000Z'
The date
The date as text such as '2024-01-15T14:30:45.000Z'
Formats the date the way it appears inside JSON, which is the ISO 8601 form in UTC.
Example: 15 January 2024 at 14:30 -> '2024-01-15T14:30:00.000Z'
The date
The date as text such as '2024-01-15T14:30:00.000Z'
Formats the full date and time as text in the local time zone, with the zone offset.
Example: 15 January 2024 at 14:30 -> 'Mon Jan 15 2024 14:30:00 GMT+0000'
The date
The date and time as text
Formats the time part as text, without the date, in the local time zone with the zone offset.
Example: 15 January 2024 at 14:30 -> '14:30:45 GMT+0000'
The date
The time as text such as '14:30:45 GMT+0000'
Formats the date and time as text in UTC.
Example: 15 January 2024 at 14:30 -> 'Mon, 15 Jan 2024 14:30:00 GMT'
The date
The date and time as UTC text
Gives the current date and time at the moment of the call.
The current date and time
Builds a date from its parts, read in the local time zone.
The month counts from 0: 0 is January, 11 December. A part outside its range rolls over, so day 32 of January becomes the first of February. Example: year 2024, month 0, day 15, hours 14, minutes 30 -> 15 January 2024 at 14:30 local time
The year, month, day, hours, minutes, seconds and milliseconds
The date
Builds a date from its parts, read as UTC so the local time zone plays no part.
The month counts from 0: 0 is January, 11 December. A part outside its range rolls over. Example: year 2024, month 0, day 15 -> 15 January 2024 at 00:00 UTC
The year, month, day, hours, minutes, seconds and milliseconds
The date
Builds a date from a Unix timestamp: the number of milliseconds since 1 January 1970 at 00:00 UTC.
Example: 1705329000000 -> 15 January 2024 at 14:30 UTC
The timestamp in milliseconds
The date
Reads the day of the month, from 1 to 31, in the local time zone.
Example: 15 January 2024 -> 15
The date
The day of the month
Reads the day of the week in the local time zone: 0 is Sunday, 6 Saturday.
Example: 15 January 2024 -> 1, a Monday
The date
The weekday from 0 to 6
Reads the full year in the local time zone.
Example: 15 January 2024 -> 2024
The date
The year
Reads the month in the local time zone, counting from 0: 0 is January, 11 December.
Example: 15 January 2024 -> 0
The date
The month from 0 to 11
Reads the hour, from 0 to 23, in the local time zone.
Example: 14:30 -> 14
The date
The hour
Reads the minutes, from 0 to 59, in the local time zone.
Example: 14:30 -> 30
The date
The minutes
Reads the seconds, from 0 to 59, in the local time zone.
Example: 14:30:45 -> 45
The date
The seconds
Reads the milliseconds, from 0 to 999, in the local time zone.
Example: 14:30:45.123 -> 123
The date
The milliseconds
Gives the date as a Unix timestamp: the milliseconds since 1 January 1970 at 00:00 UTC.
Example: 15 January 2024 at 14:30 UTC -> 1705329000000
The date
The timestamp in milliseconds
Reads the full year in UTC.
Example: 15 January 2024 -> 2024
The date
The year
Reads the month in UTC, counting from 0: 0 is January, 11 December.
Example: 15 January 2024 -> 0
The date
The month from 0 to 11
Reads the day of the month, from 1 to 31, in UTC.
Example: 15 January 2024 -> 15
The date
The day of the month
Reads the hour, from 0 to 23, in UTC.
Example: 14:00 UTC -> 14
The date
The hour
Reads the minutes, from 0 to 59, in UTC.
Example: 14:30 UTC -> 30
The date
The minutes
Reads the seconds, from 0 to 59, in UTC.
Example: 14:30:45 UTC -> 45
The date
The seconds
Reads the milliseconds, from 0 to 999, in UTC.
Example: 14:30:45.123 UTC -> 123
The date
The milliseconds
Reads a date written as text and gives its Unix timestamp, the milliseconds since 1 January 1970 at 00:00 UTC.
ISO 8601 text such as '2024-01-15' or '2024-01-15T14:30:00Z' is read reliably; text that cannot be read gives NaN. Example: '2024-01-15' -> 1705276800000
The date as text
The timestamp in milliseconds, or NaN when the text is not a date
Makes a copy of the date with another year, in the local time zone. The given date is not changed.
Example: 15 January 2024 with year 2025 -> 15 January 2025
The date and the year
A new date with the year changed
Makes a copy of the date with another month, in the local time zone; months count from 0. The given date is not changed.
Example: 15 January 2024 with month 5 -> 15 June 2024
The date and the month from 0 to 11
A new date with the month changed
Makes a copy of the date with another day of the month, in the local time zone. The given date is not changed.
Example: 15 January 2024 with day 20 -> 20 January 2024
The date and the day from 1 to 31
A new date with the day changed
Makes a copy of the date with another hour, in the local time zone. The given date is not changed.
Example: 14:30 with hours 9 -> 09:30
The date and the hour from 0 to 23
A new date with the hour changed
Makes a copy of the date with other minutes, in the local time zone. The given date is not changed.
Example: 14:30 with minutes 45 -> 14:45
The date and the minutes from 0 to 59
A new date with the minutes changed
Makes a copy of the date with other seconds, in the local time zone. The given date is not changed.
Example: 14:30:00 with seconds 30 -> 14:30:30
The date and the seconds from 0 to 59
A new date with the seconds changed
Makes a copy of the date with other milliseconds, in the local time zone. The given date is not changed.
Example: 14:30:00.000 with milliseconds 500 -> 14:30:00.500
The date and the milliseconds from 0 to 999
A new date with the milliseconds changed
Makes a copy of the date moved to a Unix timestamp, the milliseconds since 1 January 1970 at 00:00 UTC. The given date is not changed.
Example: any date with time 0 -> 1 January 1970 at 00:00 UTC
The date and the timestamp in milliseconds
A new date with the timestamp changed
Makes a copy of the date with another year, in UTC. The given date is not changed.
Example: 15 January 2024 with year 2025 -> 15 January 2025
The date and the year
A new date with the year changed
Makes a copy of the date with another month, in UTC; months count from 0. The given date is not changed.
Example: 15 January 2024 with month 5 -> 15 June 2024
The date and the month from 0 to 11
A new date with the month changed
Makes a copy of the date with another day of the month, in UTC. The given date is not changed.
Example: 15 January 2024 with day 20 -> 20 January 2024
The date and the day from 1 to 31
A new date with the day changed
Makes a copy of the date with another hour, in UTC. The given date is not changed.
Example: 14:30 UTC with hours 9 -> 09:30 UTC
The date and the hour from 0 to 23
A new date with the hour changed
Makes a copy of the date with other minutes, in UTC. The given date is not changed.
Example: 14:30 UTC with minutes 45 -> 14:45 UTC
The date and the minutes from 0 to 59
A new date with the minutes changed
Makes a copy of the date with other seconds, in UTC. The given date is not changed.
Example: 14:30:00 UTC with seconds 30 -> 14:30:30 UTC
The date and the seconds from 0 to 59
A new date with the seconds changed
Makes a copy of the date with other milliseconds, in UTC. The given date is not changed.
Example: 14:30:00.000 UTC with milliseconds 500 -> 14:30:00.500 UTC
The date and the milliseconds from 0 to 999
A new date with the milliseconds changed
Dates and times as JavaScript
Datevalues: creating them, reading and setting their parts, and formatting them as text. Months count from 0 (January is 0, December 11) and weekdays from 0 (Sunday); days of the month count from 1. Every setter returns a new date and leaves the given one unchanged. Local-time and UTC variants exist for most operations.