Date (Standard - JavaScript)

Represents a date and time.

Defined in

Standard (JavaScript)

Usage

Absolute times are given as Coordinated Universal Time (UTC). Other times are adjusted for the time zone of the computer running the script. This means the server for server-side scripts.
As a numeric (long) value, a date is the number of milliseconds relative to January 1, 1970 at 12:00 AM UTC. For example:
  • January 1, 1970 at 12:00 AM UTC has a numeric value of 0.
  • January 1, 1970 at 12:01 AM UTC has a numeric value of 60,000 (60 seconds times 1000 milliseconds).
  • January 1, 1970 at 1:00 AM UTC has a numeric value of 3,600,000.
  • January 2, 1970 at 12:00 AM UTC has a numeric value of 86,400,000.
  • December 31, 1969 at 12:00 AM UTC has a numeric value of -86,400,000.
Integer specifications are as follows:
  • Year specifications are not abbreviated. Do not specify 07 for 2007; 07 means the year 7. However, the formatted date usually abbreviates the year which can cause confusion. To be sure of the year, use getFullYear (JavaScript) or setUTCFullYear (JavaScript).
  • Month specifications are zero-based. January is 0 and December is 11. If you set a month outside this range, it is accepted without error modulo 12 with adjustments for the year; for example, 12 is month 0 of the next year, 13 is month 1 of the next year, and -1 is month 11 of the previous year.
  • Day specifications start with 1 for the first day of the month. If you set a day outside the days in a month, it is accepted without error modulo the number of days in the month plus 1 with adjustments for the month; for example, if a month has 31 days, 32 is day 1 of the next month, 33 is day 2 of the next month, and -1 is the last day of the previous month.
  • Day of the week specifications start with 0 for Sunday.
  • Hour specifications are 0 through 23. If you set an hour outside the hours in a day, it is accepted without error modulo 24 with adjustments for the day; for example, 25 is 1:00 AM the next day and -1 is 11:00 PM the previous day.
  • Minute specifications are 0 through 59. If you set a minute outside the minutes in an hour, it is accepted without error modulo 60 with adjustments for the hour.
  • Second specifications are 0 through 59. If you set a second outside the seconds in a minute, it is accepted without error modulo 60 with adjustments for the minute.
  • Millisecond specifications are 0 through 999. If you set a millisecond outside the milliseconds in a second, it is accepted without error modulo 1000 with adjustments for the second.