21.4 Date Objects

21.4.1 Overview of Date Objects and Definitions of Abstract Operations

The following functions are abstract operations that operate on time values (defined in 21.4.1.1). Note that, in every case, if any argument to one of these functions is NaN, the result will be NaN.

21.4.1.1 Time Values and Time Range

Time measurement in ECMAScript is analogous to time measurement in POSIX, in particular sharing definition in terms of the proleptic Gregorian calendar, an epoch of midnight at the beginning of 1 January 1970 UTC, and an accounting of every day as comprising exactly 86,400 seconds (each of which is 1000 milliseconds long).

An ECMAScript time value is a Number, either a finite integral Number representing an instant in time to millisecond precision or NaN representing no specific instant. A time value that is a multiple of 24 × 60 × 60 × 1000 = 86,400,000 (i.e., is equal to 86,400,000 × d for some integer d) represents the instant at the start of the UTC day that follows the epoch by d whole UTC days (preceding the epoch for negative d). Every other finite time value t is defined relative to the greatest preceding time value s that is such a multiple, and represents the instant that occurs within the same UTC day as s but follows it by ts milliseconds.

Time values do not account for UTC leap seconds—there are no time values representing instants within positive leap seconds, and there are time values representing instants removed from the UTC timeline by negative leap seconds. However, the definition of time values nonetheless yields piecewise alignment with UTC, with discontinuities only at leap second boundaries and zero difference outside of leap seconds.

A Number can exactly represent all integers from -9,007,199,254,740,992 to 9,007,199,254,740,992 (21.1.2.8 and 21.1.2.6). A time value supports a slightly smaller range of -8,640,000,000,000,000 to 8,640,000,000,000,000 milliseconds. This yields a supported time value range of exactly -100,000,000 days to 100,000,000 days relative to midnight at the beginning of 1 January 1970 UTC.

The exact moment of midnight at the beginning of 1 January 1970 UTC is represented by the time value +0𝔽.

Note

The 400 year cycle of the proleptic Gregorian calendar contains 97 leap years. This yields an average of 365.2425 days per year, which is 31,556,952,000 milliseconds. Therefore, the maximum range a Number could represent exactly with millisecond precision is approximately -285,426 to 285,426 years relative to 1970. The smaller range supported by a time value as specified in this section is approximately -273,790 to 273,790 years relative to 1970.

21.4.1.2 Day Number and Time within Day

A given time value t belongs to day number

Day(t) = 𝔽(floor((t / msPerDay)))

where the number of milliseconds per day is

msPerDay = 86400000𝔽

The remainder is called the time within the day:

TimeWithinDay(t) = 𝔽((t) modulo (msPerDay))

21.4.1.3 Year Number

ECMAScript uses a proleptic Gregorian calendar to map a day number to a year number and to determine the month and date within that year. In this calendar, leap years are precisely those which are (divisible by 4) and ((not divisible by 100) or (divisible by 400)). The number of days in year number y is therefore defined by

DaysInYear(y)
= 365𝔽 if ((y) modulo 4) ≠ 0
= 366𝔽 if ((y) modulo 4) = 0 and ((y) modulo 100) ≠ 0
= 365𝔽 if ((y) modulo 100) = 0 and ((y) modulo 400) ≠ 0
= 366𝔽 if ((y) modulo 400) = 0

All non-leap years have 365 days with the usual number of days per month and leap years have an extra day in February. The day number of the first day of year y is given by:

DayFromYear(y) = 𝔽(365 × ((y) - 1970) + floor(((y) - 1969) / 4) - floor(((y) - 1901) / 100) + floor(((y) - 1601) / 400))

The time value of the start of a year is:

TimeFromYear(y) = msPerDay × DayFromYear(y)

A time value determines a year by:

YearFromTime(t) = the largest integral Number y (closest to +∞) such that TimeFromYear(y) ≤ t

The leap-year function is 1𝔽 for a time within a leap year and otherwise is +0𝔽:

InLeapYear(t)
= +0𝔽 if DaysInYear(YearFromTime(t)) = 365𝔽
= 1𝔽 if DaysInYear(YearFromTime(t)) = 366𝔽

21.4.1.4 Month Number

Months are identified by an integral Number in the range +0𝔽 to 11𝔽, inclusive. The mapping MonthFromTime(t) from a time value t to a month number is defined by:

MonthFromTime(t)
= +0𝔽 if +0𝔽DayWithinYear(t) < 31𝔽
= 1𝔽 if 31𝔽DayWithinYear(t) < 59𝔽 + InLeapYear(t)
= 2𝔽 if 59𝔽 + InLeapYear(t) ≤ DayWithinYear(t) < 90𝔽 + InLeapYear(t)
= 3𝔽 if 90𝔽 + InLeapYear(t) ≤ DayWithinYear(t) < 120𝔽 + InLeapYear(t)
= 4𝔽 if 120𝔽 + InLeapYear(t) ≤ DayWithinYear(t) < 151𝔽 + InLeapYear(t)
= 5𝔽 if 151𝔽 + InLeapYear(t) ≤ DayWithinYear(t) < 181𝔽 + InLeapYear(t)
= 6𝔽 if 181𝔽 + InLeapYear(t) ≤ DayWithinYear(t) < 212𝔽 + InLeapYear(t)
= 7𝔽 if 212𝔽 + InLeapYear(t) ≤ DayWithinYear(t) < 243𝔽 + InLeapYear(t)
= 8𝔽 if 243𝔽 + InLeapYear(t) ≤ DayWithinYear(t) < 273𝔽 + InLeapYear(t)
= 9𝔽 if 273𝔽 + InLeapYear(t) ≤ DayWithinYear(t) < 304𝔽 + InLeapYear(t)
= 10𝔽 if 304𝔽 + InLeapYear(t) ≤ DayWithinYear(t) < 334𝔽 + InLeapYear(t)
= 11𝔽 if 334𝔽 + InLeapYear(t) ≤ DayWithinYear(t) < 365𝔽 + InLeapYear(t)

where

DayWithinYear(t) = Day(t) - DayFromYear(YearFromTime(t))

A month value of +0𝔽 specifies January; 1𝔽 specifies February; 2𝔽 specifies March; 3𝔽 specifies April; 4𝔽 specifies May; 5𝔽 specifies June; 6𝔽 specifies July; 7𝔽 specifies August; 8𝔽 specifies September; 9𝔽 specifies October; 10𝔽 specifies November; and 11𝔽 specifies December. Note that MonthFromTime(+0𝔽) = +0𝔽, corresponding to Thursday, 1 January 1970.

21.4.1.5 Date Number

A date number is identified by an integral Number in the range 1𝔽 through 31𝔽, inclusive. The mapping DateFromTime(t) from a time value t to a date number is defined by:

DateFromTime(t)
= DayWithinYear(t) + 1𝔽 if MonthFromTime(t) = +0𝔽
= DayWithinYear(t) - 30𝔽 if MonthFromTime(t) = 1𝔽
= DayWithinYear(t) - 58𝔽 - InLeapYear(t) if MonthFromTime(t) = 2𝔽
= DayWithinYear(t) - 89𝔽 - InLeapYear(t) if MonthFromTime(t) = 3𝔽
= DayWithinYear(t) - 119𝔽 - InLeapYear(t) if MonthFromTime(t) = 4𝔽
= DayWithinYear(t) - 150𝔽 - InLeapYear(t) if MonthFromTime(t) = 5𝔽
= DayWithinYear(t) - 180𝔽 - InLeapYear(t) if MonthFromTime(t) = 6𝔽
= DayWithinYear(t) - 211𝔽 - InLeapYear(t) if MonthFromTime(t) = 7𝔽
= DayWithinYear(t) - 242𝔽 - InLeapYear(t) if MonthFromTime(t) = 8𝔽
= DayWithinYear(t) - 272𝔽 - InLeapYear(t) if MonthFromTime(t) = 9𝔽
= DayWithinYear(t) - 303𝔽 - InLeapYear(t) if MonthFromTime(t) = 10𝔽
= DayWithinYear(t) - 333𝔽 - InLeapYear(t) if MonthFromTime(t) = 11𝔽

21.4.1.6 Week Day

The weekday for a particular time value t is defined as

WeekDay(t) = 𝔽((Day(t) + 4𝔽) modulo 7)

A weekday value of +0𝔽 specifies Sunday; 1𝔽 specifies Monday; 2𝔽 specifies Tuesday; 3𝔽 specifies Wednesday; 4𝔽 specifies Thursday; 5𝔽 specifies Friday; and 6𝔽 specifies Saturday. Note that WeekDay(+0𝔽) = 4𝔽, corresponding to Thursday, 1 January 1970.

21.4.1.7 LocalTZA ( t, isUTC )

LocalTZA( t, isUTC ) is an implementation-defined algorithm that returns an integral Number representing the local time zone adjustment, or offset, in milliseconds. The local political rules for standard time and daylight saving time in effect at t should be used to determine the result in the way specified in this section.

When isUTC is true, LocalTZA( tUTC, true ) should return the offset of the local time zone from UTC measured in milliseconds at time represented by time value tUTC. When the result is added to tUTC, it should yield the corresponding Number tlocal.

When isUTC is false, LocalTZA( tlocal, false ) should return the offset of the local time zone from UTC measured in milliseconds at local time represented by Number tlocal. When the result is subtracted from tlocal, it should yield the corresponding time value tUTC.

Input t is nominally a time value but may be any Number value. This can occur when isUTC is false and tlocal represents a time value that is already offset outside of the time value range at the range boundaries. The algorithm must not limit tlocal to the time value range, so that such inputs are supported.

When tlocal represents local time repeating multiple times at a negative time zone transition (e.g. when the daylight saving time ends or the time zone offset is decreased due to a time zone rule change) or skipped local time at a positive time zone transitions (e.g. when the daylight saving time starts or the time zone offset is increased due to a time zone rule change), tlocal must be interpreted using the time zone offset before the transition.

If an implementation does not support a conversion described above or if political rules for time t are not available within the implementation, the result must be +0𝔽.

Note

It is recommended that implementations use the time zone information of the IANA Time Zone Database https://www.iana.org/time-zones/.

1:30 AM on 5 November 2017 in America/New_York is repeated twice (fall backward), but it must be interpreted as 1:30 AM UTC-04 instead of 1:30 AM UTC-05. LocalTZA(TimeClip(MakeDate(MakeDay(2017, 10, 5), MakeTime(1, 30, 0, 0))), false) is -4 × msPerHour.

2:30 AM on 12 March 2017 in America/New_York does not exist, but it must be interpreted as 2:30 AM UTC-05 (equivalent to 3:30 AM UTC-04). LocalTZA(TimeClip(MakeDate(MakeDay(2017, 2, 12), MakeTime(2, 30, 0, 0))), false) is -5 × msPerHour.

Local time zone offset values may be positive or negative.

21.4.1.8 LocalTime ( t )

The abstract operation LocalTime takes argument t. It converts t from UTC to local time. It performs the following steps when called:

  1. Return t + LocalTZA(t, true).
Note

Two different input time values tUTC are converted to the same local time tlocal at a negative time zone transition when there are repeated times (e.g. the daylight saving time ends or the time zone adjustment is decreased.).

LocalTime(UTC(tlocal)) is not necessarily always equal to tlocal. Correspondingly, UTC(LocalTime(tUTC)) is not necessarily always equal to tUTC.

21.4.1.9 UTC ( t )

The abstract operation UTC takes argument t. It converts t from local time to UTC. It performs the following steps when called:

  1. Return t - LocalTZA(t, false).
Note

UTC(LocalTime(tUTC)) is not necessarily always equal to tUTC. Correspondingly, LocalTime(UTC(tlocal)) is not necessarily always equal to tlocal.

21.4.1.10 Hours, Minutes, Second, and Milliseconds

The following abstract operations are useful in decomposing time values:

HourFromTime(t) = 𝔽(floor((t / msPerHour)) modulo HoursPerDay)
MinFromTime(t) = 𝔽(floor((t / msPerMinute)) modulo MinutesPerHour)
msFromTime(t) = 𝔽((t) modulo msPerSecond)

where

HoursPerDay = 24
MinutesPerHour = 60
SecondsPerMinute = 60
msPerSecond = 1000𝔽
msPerMinute = 60000𝔽 = msPerSecond × 𝔽(SecondsPerMinute)
msPerHour = 3600000𝔽 = msPerMinute × 𝔽(MinutesPerHour)

21.4.1.11 MakeTime ( hour, min, sec, ms )

The abstract operation MakeTime takes arguments hour (a Number), min (a Number), sec (a Number), and ms (a Number). It calculates a number of milliseconds. It performs the following steps when called:

  1. If hour is not finite or min is not finite or sec is not finite or ms is not finite, return NaN.
  2. Let h be 𝔽(! ToIntegerOrInfinity(hour)).
  3. Let m be 𝔽(! ToIntegerOrInfinity(min)).
  4. Let s be 𝔽(! ToIntegerOrInfinity(sec)).
  5. Let milli be 𝔽(! ToIntegerOrInfinity(ms)).
  6. Let t be ((h * msPerHour + m * msPerMinute) + s * msPerSecond) + milli, performing the arithmetic according to IEEE 754-2019 rules (that is, as if using the ECMAScript operators * and +).
  7. Return t.

21.4.1.12 MakeDay ( year, month, date )

The abstract operation MakeDay takes arguments year (a Number), month (a Number), and date (a Number). It calculates a number of days. It performs the following steps when called:

  1. If year is not finite or month is not finite or date is not finite, return NaN.
  2. Let y be 𝔽(! ToIntegerOrInfinity(year)).
  3. Let m be 𝔽(! ToIntegerOrInfinity(month)).
  4. Let dt be 𝔽(! ToIntegerOrInfinity(date)).
  5. Let ym be y + 𝔽(floor((m) / 12)).
  6. If ym is not finite, return NaN.
  7. Let mn be 𝔽((m) modulo 12).
  8. Find a finite time value t such that YearFromTime(t) is ym and MonthFromTime(t) is mn and DateFromTime(t) is 1𝔽; but if this is not possible (because some argument is out of range), return NaN.
  9. Return Day(t) + dt - 1𝔽.

21.4.1.13 MakeDate ( day, time )

The abstract operation MakeDate takes arguments day (a Number) and time (a Number). It calculates a number of milliseconds. It performs the following steps when called:

  1. If day is not finite or time is not finite, return NaN.
  2. Let tv be day × msPerDay + time.
  3. If tv is not finite, return NaN.
  4. Return tv.

21.4.1.14 TimeClip ( time )

The abstract operation TimeClip takes argument time (a Number). It calculates a number of milliseconds. It performs the following steps when called:

  1. If time is not finite, return NaN.
  2. If abs((time)) > 8.64 × 1015, return NaN.
  3. Return 𝔽(! ToIntegerOrInfinity(time)).

21.4.1.15 Date Time String Format

ECMAScript defines a string interchange format for date-times based upon a simplification of the ISO 8601 calendar date extended format. The format is as follows: YYYY-MM-DDTHH:mm:ss.sssZ

Where the elements are as follows:

YYYY is the year in the proleptic Gregorian calendar as four decimal digits from 0000 to 9999, or as an expanded year of "+" or "-" followed by six decimal digits.
- "-" (hyphen) appears literally twice in the string.
MM is the month of the year as two decimal digits from 01 (January) to 12 (December).
DD is the day of the month as two decimal digits from 01 to 31.
T "T" appears literally in the string, to indicate the beginning of the time element.
HH is the number of complete hours that have passed since midnight as two decimal digits from 00 to 24.
: ":" (colon) appears literally twice in the string.
mm is the number of complete minutes since the start of the hour as two decimal digits from 00 to 59.
ss is the number of complete seconds since the start of the minute as two decimal digits from 00 to 59.
. "." (dot) appears literally in the string.
sss is the number of complete milliseconds since the start of the second as three decimal digits.
Z is the UTC offset representation specified as "Z" (for UTC with no offset) or an offset of either "+" or "-" followed by a time expression HH:mm (indicating local time ahead of or behind UTC, respectively)

This format includes date-only forms:

YYYY
YYYY-MM
YYYY-MM-DD
        

It also includes “date-time” forms that consist of one of the above date-only forms immediately followed by one of the following time forms with an optional UTC offset representation appended:

THH:mm
THH:mm:ss
THH:mm:ss.sss
        

A string containing out-of-bounds or nonconforming elements is not a valid instance of this format.

Note 1

As every day both starts and ends with midnight, the two notations 00:00 and 24:00 are available to distinguish the two midnights that can be associated with one date. This means that the following two notations refer to exactly the same point in time: 1995-02-04T24:00 and 1995-02-05T00:00. This interpretation of the latter form as "end of a calendar day" is consistent with ISO 8601, even though that specification reserves it for describing time intervals and does not permit it within representations of single points in time.

Note 2

There exists no international standard that specifies abbreviations for civil time zones like CET, EST, etc. and sometimes the same abbreviation is even used for two very different time zones. For this reason, both ISO 8601 and this format specify numeric representations of time zone offsets.

21.4.1.15.1 Expanded Years

Covering the full time value range of approximately 273,790 years forward or backward from 1 January 1970 (21.4.1.1) requires representing years before 0 or after 9999. ISO 8601 permits expansion of the year representation, but only by mutual agreement of the partners in information interchange. In the simplified ECMAScript format, such an expanded year representation shall have 6 digits and is always prefixed with a + or - sign. The year 0 is considered positive and hence prefixed with a + sign. Strings matching the Date Time String Format with expanded years representing instants in time outside the range of a time value are treated as unrecognizable by Date.parse and cause that function to return NaN without falling back to implementation-specific behaviour or heuristics.

Note

Examples of date-time values with expanded years:

-271821-04-20T00:00:00Z 271822 B.C.
-000001-01-01T00:00:00Z 2 B.C.
+000000-01-01T00:00:00Z 1 B.C.
+000001-01-01T00:00:00Z 1 A.D.
+001970-01-01T00:00:00Z 1970 A.D.
+002009-12-15T00:00:00Z 2009 A.D.
+275760-09-13T00:00:00Z 275760 A.D.

21.4.2 The Date Constructor

The Date constructor:

  • is %Date%.
  • is the initial value of the "Date" property of the global object.
  • creates and initializes a new Date object when called as a constructor.
  • returns a String representing the current time (UTC) when called as a function rather than as a constructor.
  • is a function whose behaviour differs based upon the number and types of its arguments.
  • is designed to be subclassable. It may be used as the value of an extends clause of a class definition. Subclass constructors that intend to inherit the specified Date behaviour must include a super call to the Date constructor to create and initialize the subclass instance with a [[DateValue]] internal slot.
  • has a "length" property whose value is 7𝔽.

21.4.2.1 Date ( ...values )

When the Date function is called, the following steps are taken:

  1. If NewTarget is undefined, then
    1. Let now be the time value (UTC) identifying the current time.
    2. Return ToDateString(now).
  2. Let numberOfArgs be the number of elements in values.
  3. If numberOfArgs = 0, then
    1. Let dv be the time value (UTC) identifying the current time.
  4. Else if numberOfArgs = 1, then
    1. Let value be values[0].
    2. If Type(value) is Object and value has a [[DateValue]] internal slot, then
      1. Let tv be ! thisTimeValue(value).
    3. Else,
      1. Let v be ? ToPrimitive(value).
      2. If Type(v) is String, then
        1. Assert: The next step never returns an abrupt completion because Type(v) is String.
        2. Let tv be the result of parsing v as a date, in exactly the same manner as for the parse method (21.4.3.2).
      3. Else,
        1. Let tv be ? ToNumber(v).
    4. Let dv be TimeClip(tv).
  5. Else,
    1. Assert: numberOfArgs ≥ 2.
    2. Let y be ? ToNumber(values[0]).
    3. Let m be ? ToNumber(values[1]).
    4. If numberOfArgs > 2, let dt be ? ToNumber(values[2]); else let dt be 1𝔽.
    5. If numberOfArgs > 3, let h be ? ToNumber(values[3]); else let h be +0𝔽.
    6. If numberOfArgs > 4, let min be ? ToNumber(values[4]); else let min be +0𝔽.
    7. If numberOfArgs > 5, let s be ? ToNumber(values[5]); else let s be +0𝔽.
    8. If numberOfArgs > 6, let milli be ? ToNumber(values[6]); else let milli be +0𝔽.
    9. If y is NaN, let yr be NaN.
    10. Else,
      1. Let yi be ! ToIntegerOrInfinity(y).
      2. If 0 ≤ yi ≤ 99, let yr be 1900𝔽 + 𝔽(yi); otherwise, let yr be y.
    11. Let finalDate be MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli)).
    12. Let dv be TimeClip(UTC(finalDate)).
  6. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Date.prototype%", « [[DateValue]] »).
  7. Set O.[[DateValue]] to dv.
  8. Return O.

21.4.3 Properties of the Date Constructor

The Date constructor:

  • has a [[Prototype]] internal slot whose value is %Function.prototype%.
  • has the following properties:

21.4.3.1 Date.now ( )

The now function returns the time value designating the UTC date and time of the occurrence of the call to now.

21.4.3.2 Date.parse ( string )

The parse function applies the ToString operator to its argument. If ToString results in an abrupt completion the Completion Record is immediately returned. Otherwise, parse interprets the resulting String as a date and time; it returns a Number, the UTC time value corresponding to the date and time. The String may be interpreted as a local time, a UTC time, or a time in some other time zone, depending on the contents of the String. The function first attempts to parse the String according to the format described in Date Time String Format (21.4.1.15), including expanded years. If the String does not conform to that format the function may fall back to any implementation-specific heuristics or implementation-specific date formats. Strings that are unrecognizable or contain out-of-bounds format element values shall cause Date.parse to return NaN.

If the String conforms to the Date Time String Format, substitute values take the place of absent format elements. When the MM or DD elements are absent, "01" is used. When the HH, mm, or ss elements are absent, "00" is used. When the sss element is absent, "000" is used. When the UTC offset representation is absent, date-only forms are interpreted as a UTC time and date-time forms are interpreted as a local time.

If x is any Date object whose milliseconds amount is zero within a particular implementation of ECMAScript, then all of the following expressions should produce the same numeric value in that implementation, if all the properties referenced have their initial values:

x.valueOf()
Date.parse(x.toString())
Date.parse(x.toUTCString())
Date.parse(x.toISOString())

However, the expression

Date.parse(x.toLocaleString())

is not required to produce the same Number value as the preceding three expressions and, in general, the value produced by Date.parse is implementation-defined when given any String value that does not conform to the Date Time String Format (21.4.1.15) and that could not be produced in that implementation by the toString or toUTCString method.

21.4.3.3 Date.prototype

The initial value of Date.prototype is the Date prototype object.

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

21.4.3.4 Date.UTC ( year [ , month [ , date [ , hours [ , minutes [ , seconds [ , ms ] ] ] ] ] ] )

When the UTC function is called, the following steps are taken:

  1. Let y be ? ToNumber(year).
  2. If month is present, let m be ? ToNumber(month); else let m be +0𝔽.
  3. If date is present, let dt be ? ToNumber(date); else let dt be 1𝔽.
  4. If hours is present, let h be ? ToNumber(hours); else let h be +0𝔽.
  5. If minutes is present, let min be ? ToNumber(minutes); else let min be +0𝔽.
  6. If seconds is present, let s be ? ToNumber(seconds); else let s be +0𝔽.
  7. If ms is present, let milli be ? ToNumber(ms); else let milli be +0𝔽.
  8. If y is NaN, let yr be NaN.
  9. Else,
    1. Let yi be ! ToIntegerOrInfinity(y).
    2. If 0 ≤ yi ≤ 99, let yr be 1900𝔽 + 𝔽(yi); otherwise, let yr be y.
  10. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))).

The "length" property of the UTC function is 7𝔽.

Note

The UTC function differs from the Date constructor in two ways: it returns a time value as a Number, rather than creating a Date object, and it interprets the arguments in UTC rather than as local time.

21.4.4 Properties of the Date Prototype Object

The Date prototype object:

  • is %Date.prototype%.
  • is itself an ordinary object.
  • is not a Date instance and does not have a [[DateValue]] internal slot.
  • has a [[Prototype]] internal slot whose value is %Object.prototype%.

Unless explicitly defined otherwise, the methods of the Date prototype object defined below are not generic and the this value passed to them must be an object that has a [[DateValue]] internal slot that has been initialized to a time value.

The abstract operation thisTimeValue takes argument value. It performs the following steps when called:

  1. If Type(value) is Object and value has a [[DateValue]] internal slot, then
    1. Return value.[[DateValue]].
  2. Throw a TypeError exception.

In following descriptions of functions that are properties of the Date prototype object, the phrase “this Date object” refers to the object that is the this value for the invocation of the function. If the Type of the this value is not Object, a TypeError exception is thrown. The phrase “this time value” within the specification of a method refers to the result returned by calling the abstract operation thisTimeValue with the this value of the method invocation passed as the argument.

21.4.4.1 Date.prototype.constructor

The initial value of Date.prototype.constructor is %Date%.

21.4.4.2 Date.prototype.getDate ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return DateFromTime(LocalTime(t)).

21.4.4.3 Date.prototype.getDay ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return WeekDay(LocalTime(t)).

21.4.4.4 Date.prototype.getFullYear ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return YearFromTime(LocalTime(t)).

21.4.4.5 Date.prototype.getHours ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return HourFromTime(LocalTime(t)).

21.4.4.6 Date.prototype.getMilliseconds ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return msFromTime(LocalTime(t)).

21.4.4.7 Date.prototype.getMinutes ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return MinFromTime(LocalTime(t)).

21.4.4.8 Date.prototype.getMonth ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return MonthFromTime(LocalTime(t)).

21.4.4.9 Date.prototype.getSeconds ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return SecFromTime(LocalTime(t)).

21.4.4.10 Date.prototype.getTime ( )

The following steps are performed:

  1. Return ? thisTimeValue(this value).

21.4.4.11 Date.prototype.getTimezoneOffset ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return (t - LocalTime(t)) / msPerMinute.

21.4.4.12 Date.prototype.getUTCDate ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return DateFromTime(t).

21.4.4.13 Date.prototype.getUTCDay ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return WeekDay(t).

21.4.4.14 Date.prototype.getUTCFullYear ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return YearFromTime(t).

21.4.4.15 Date.prototype.getUTCHours ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return HourFromTime(t).

21.4.4.16 Date.prototype.getUTCMilliseconds ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return msFromTime(t).

21.4.4.17 Date.prototype.getUTCMinutes ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return MinFromTime(t).

21.4.4.18 Date.prototype.getUTCMonth ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return MonthFromTime(t).

21.4.4.19 Date.prototype.getUTCSeconds ( )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, return NaN.
  3. Return SecFromTime(t).

21.4.4.20 Date.prototype.setDate ( date )

The following steps are performed:

  1. Let t be LocalTime(? thisTimeValue(this value)).
  2. Let dt be ? ToNumber(date).
  3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), TimeWithinDay(t)).
  4. Let u be TimeClip(UTC(newDate)).
  5. Set the [[DateValue]] internal slot of this Date object to u.
  6. Return u.

21.4.4.21 Date.prototype.setFullYear ( year [ , month [ , date ] ] )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, set t to +0𝔽; otherwise, set t to LocalTime(t).
  3. Let y be ? ToNumber(year).
  4. If month is not present, let m be MonthFromTime(t); otherwise, let m be ? ToNumber(month).
  5. If date is not present, let dt be DateFromTime(t); otherwise, let dt be ? ToNumber(date).
  6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)).
  7. Let u be TimeClip(UTC(newDate)).
  8. Set the [[DateValue]] internal slot of this Date object to u.
  9. Return u.

The "length" property of the setFullYear method is 3𝔽.

Note

If month is not present, this method behaves as if month was present with the value getMonth(). If date is not present, it behaves as if date was present with the value getDate().

21.4.4.22 Date.prototype.setHours ( hour [ , min [ , sec [ , ms ] ] ] )

The following steps are performed:

  1. Let t be LocalTime(? thisTimeValue(this value)).
  2. Let h be ? ToNumber(hour).
  3. If min is not present, let m be MinFromTime(t); otherwise, let m be ? ToNumber(min).
  4. If sec is not present, let s be SecFromTime(t); otherwise, let s be ? ToNumber(sec).
  5. If ms is not present, let milli be msFromTime(t); otherwise, let milli be ? ToNumber(ms).
  6. Let date be MakeDate(Day(t), MakeTime(h, m, s, milli)).
  7. Let u be TimeClip(UTC(date)).
  8. Set the [[DateValue]] internal slot of this Date object to u.
  9. Return u.

The "length" property of the setHours method is 4𝔽.

Note

If min is not present, this method behaves as if min was present with the value getMinutes(). If sec is not present, it behaves as if sec was present with the value getSeconds(). If ms is not present, it behaves as if ms was present with the value getMilliseconds().

21.4.4.23 Date.prototype.setMilliseconds ( ms )

The following steps are performed:

  1. Let t be LocalTime(? thisTimeValue(this value)).
  2. Set ms to ? ToNumber(ms).
  3. Let time be MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms).
  4. Let u be TimeClip(UTC(MakeDate(Day(t), time))).
  5. Set the [[DateValue]] internal slot of this Date object to u.
  6. Return u.

21.4.4.24 Date.prototype.setMinutes ( min [ , sec [ , ms ] ] )

The following steps are performed:

  1. Let t be LocalTime(? thisTimeValue(this value)).
  2. Let m be ? ToNumber(min).
  3. If sec is not present, let s be SecFromTime(t); otherwise, let s be ? ToNumber(sec).
  4. If ms is not present, let milli be msFromTime(t); otherwise, let milli be ? ToNumber(ms).
  5. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), m, s, milli)).
  6. Let u be TimeClip(UTC(date)).
  7. Set the [[DateValue]] internal slot of this Date object to u.
  8. Return u.

The "length" property of the setMinutes method is 3𝔽.

Note

If sec is not present, this method behaves as if sec was present with the value getSeconds(). If ms is not present, this behaves as if ms was present with the value getMilliseconds().

21.4.4.25 Date.prototype.setMonth ( month [ , date ] )

The following steps are performed:

  1. Let t be LocalTime(? thisTimeValue(this value)).
  2. Let m be ? ToNumber(month).
  3. If date is not present, let dt be DateFromTime(t); otherwise, let dt be ? ToNumber(date).
  4. Let newDate be MakeDate(MakeDay(YearFromTime(t), m, dt), TimeWithinDay(t)).
  5. Let u be TimeClip(UTC(newDate)).
  6. Set the [[DateValue]] internal slot of this Date object to u.
  7. Return u.

The "length" property of the setMonth method is 2𝔽.

Note

If date is not present, this method behaves as if date was present with the value getDate().

21.4.4.26 Date.prototype.setSeconds ( sec [ , ms ] )

The following steps are performed:

  1. Let t be LocalTime(? thisTimeValue(this value)).
  2. Let s be ? ToNumber(sec).
  3. If ms is not present, let milli be msFromTime(t); otherwise, let milli be ? ToNumber(ms).
  4. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), s, milli)).
  5. Let u be TimeClip(UTC(date)).
  6. Set the [[DateValue]] internal slot of this Date object to u.
  7. Return u.

The "length" property of the setSeconds method is 2𝔽.

Note

If ms is not present, this method behaves as if ms was present with the value getMilliseconds().

21.4.4.27 Date.prototype.setTime ( time )

The following steps are performed:

  1. Perform ? thisTimeValue(this value).
  2. Let t be ? ToNumber(time).
  3. Let v be TimeClip(t).
  4. Set the [[DateValue]] internal slot of this Date object to v.
  5. Return v.

21.4.4.28 Date.prototype.setUTCDate ( date )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. Let dt be ? ToNumber(date).
  3. Let newDate be MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), dt), TimeWithinDay(t)).
  4. Let v be TimeClip(newDate).
  5. Set the [[DateValue]] internal slot of this Date object to v.
  6. Return v.

21.4.4.29 Date.prototype.setUTCFullYear ( year [ , month [ , date ] ] )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. If t is NaN, set t to +0𝔽.
  3. Let y be ? ToNumber(year).
  4. If month is not present, let m be MonthFromTime(t); otherwise, let m be ? ToNumber(month).
  5. If date is not present, let dt be DateFromTime(t); otherwise, let dt be ? ToNumber(date).
  6. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)).
  7. Let v be TimeClip(newDate).
  8. Set the [[DateValue]] internal slot of this Date object to v.
  9. Return v.

The "length" property of the setUTCFullYear method is 3𝔽.

Note

If month is not present, this method behaves as if month was present with the value getUTCMonth(). If date is not present, it behaves as if date was present with the value getUTCDate().

21.4.4.30 Date.prototype.setUTCHours ( hour [ , min [ , sec [ , ms ] ] ] )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. Let h be ? ToNumber(hour).
  3. If min is not present, let m be MinFromTime(t); otherwise, let m be ? ToNumber(min).
  4. If sec is not present, let s be SecFromTime(t); otherwise, let s be ? ToNumber(sec).
  5. If ms is not present, let milli be msFromTime(t); otherwise, let milli be ? ToNumber(ms).
  6. Let newDate be MakeDate(Day(t), MakeTime(h, m, s, milli)).
  7. Let v be TimeClip(newDate).
  8. Set the [[DateValue]] internal slot of this Date object to v.
  9. Return v.

The "length" property of the setUTCHours method is 4𝔽.

Note

If min is not present, this method behaves as if min was present with the value getUTCMinutes(). If sec is not present, it behaves as if sec was present with the value getUTCSeconds(). If ms is not present, it behaves as if ms was present with the value getUTCMilliseconds().

21.4.4.31 Date.prototype.setUTCMilliseconds ( ms )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. Let milli be ? ToNumber(ms).
  3. Let time be MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), milli).
  4. Let v be TimeClip(MakeDate(Day(t), time)).
  5. Set the [[DateValue]] internal slot of this Date object to v.
  6. Return v.

21.4.4.32 Date.prototype.setUTCMinutes ( min [ , sec [ , ms ] ] )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. Let m be ? ToNumber(min).
  3. If sec is not present, let s be SecFromTime(t).
  4. Else,
    1. Let s be ? ToNumber(sec).
  5. If ms is not present, let milli be msFromTime(t).
  6. Else,
    1. Let milli be ? ToNumber(ms).
  7. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), m, s, milli)).
  8. Let v be TimeClip(date).
  9. Set the [[DateValue]] internal slot of this Date object to v.
  10. Return v.

The "length" property of the setUTCMinutes method is 3𝔽.

Note

If sec is not present, this method behaves as if sec was present with the value getUTCSeconds(). If ms is not present, it function behaves as if ms was present with the value return by getUTCMilliseconds().

21.4.4.33 Date.prototype.setUTCMonth ( month [ , date ] )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. Let m be ? ToNumber(month).
  3. If date is not present, let dt be DateFromTime(t).
  4. Else,
    1. Let dt be ? ToNumber(date).
  5. Let newDate be MakeDate(MakeDay(YearFromTime(t), m, dt), TimeWithinDay(t)).
  6. Let v be TimeClip(newDate).
  7. Set the [[DateValue]] internal slot of this Date object to v.
  8. Return v.

The "length" property of the setUTCMonth method is 2𝔽.

Note

If date is not present, this method behaves as if date was present with the value getUTCDate().

21.4.4.34 Date.prototype.setUTCSeconds ( sec [ , ms ] )

The following steps are performed:

  1. Let t be ? thisTimeValue(this value).
  2. Let s be ? ToNumber(sec).
  3. If ms is not present, let milli be msFromTime(t).
  4. Else,
    1. Let milli be ? ToNumber(ms).
  5. Let date be MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), s, milli)).
  6. Let v be TimeClip(date).
  7. Set the [[DateValue]] internal slot of this Date object to v.
  8. Return v.

The "length" property of the setUTCSeconds method is 2𝔽.

Note

If ms is not present, this method behaves as if ms was present with the value getUTCMilliseconds().

21.4.4.35 Date.prototype.toDateString ( )

The following steps are performed:

  1. Let O be this Date object.
  2. Let tv be ? thisTimeValue(O).
  3. If tv is NaN, return "Invalid Date".
  4. Let t be LocalTime(tv).
  5. Return DateString(t).

21.4.4.36 Date.prototype.toISOString ( )

If this time value is not a finite Number or if it corresponds with a year that cannot be represented in the Date Time String Format, this function throws a RangeError exception. Otherwise, it returns a String representation of this time value in that format on the UTC time scale, including all format elements and the UTC offset representation "Z".

21.4.4.37 Date.prototype.toJSON ( key )

This function provides a String representation of a Date object for use by JSON.stringify (25.5.2).

When the toJSON method is called with argument key, the following steps are taken:

  1. Let O be ? ToObject(this value).
  2. Let tv be ? ToPrimitive(O, number).
  3. If Type(tv) is Number and tv is not finite, return null.
  4. Return ? Invoke(O, "toISOString").
Note 1

The argument is ignored.

Note 2

The toJSON function is intentionally generic; it does not require that its this value be a Date object. Therefore, it can be transferred to other kinds of objects for use as a method. However, it does require that any such object have a toISOString method.

21.4.4.38 Date.prototype.toLocaleDateString ( [ reserved1 [ , reserved2 ] ] )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the Date.prototype.toLocaleDateString method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the toLocaleDateString method is used.

This function returns a String value. The contents of the String are implementation-defined, but are intended to represent the “date” portion of the Date in the current time zone in a convenient, human-readable form that corresponds to the conventions of the host environment's current locale.

The meaning of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.

21.4.4.39 Date.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the Date.prototype.toLocaleString method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the toLocaleString method is used.

This function returns a String value. The contents of the String are implementation-defined, but are intended to represent the Date in the current time zone in a convenient, human-readable form that corresponds to the conventions of the host environment's current locale.

The meaning of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.

21.4.4.40 Date.prototype.toLocaleTimeString ( [ reserved1 [ , reserved2 ] ] )

An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the Date.prototype.toLocaleTimeString method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of the toLocaleTimeString method is used.

This function returns a String value. The contents of the String are implementation-defined, but are intended to represent the “time” portion of the Date in the current time zone in a convenient, human-readable form that corresponds to the conventions of the host environment's current locale.

The meaning of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.

21.4.4.41 Date.prototype.toString ( )

The following steps are performed:

  1. Let tv be ? thisTimeValue(this value).
  2. Return ToDateString(tv).
Note 1

For any Date object d such that d.[[DateValue]] is evenly divisible by 1000, the result of Date.parse(d.toString()) = d.valueOf(). See 21.4.3.2.

Note 2

The toString function is not generic; it throws a TypeError exception if its this value is not a Date object. Therefore, it cannot be transferred to other kinds of objects for use as a method.

21.4.4.41.1 TimeString ( tv )

The abstract operation TimeString takes argument tv. It performs the following steps when called:

  1. Assert: Type(tv) is Number.
  2. Assert: tv is not NaN.
  3. Let hour be the String representation of HourFromTime(tv), formatted as a two-digit decimal number, padded to the left with the code unit 0x0030 (DIGIT ZERO) if necessary.
  4. Let minute be the String representation of MinFromTime(tv), formatted as a two-digit decimal number, padded to the left with the code unit 0x0030 (DIGIT ZERO) if necessary.
  5. Let second be the String representation of SecFromTime(tv), formatted as a two-digit decimal number, padded to the left with the code unit 0x0030 (DIGIT ZERO) if necessary.
  6. Return the string-concatenation of hour, ":", minute, ":", second, the code unit 0x0020 (SPACE), and "GMT".

21.4.4.41.2 DateString ( tv )

The abstract operation DateString takes argument tv. It performs the following steps when called:

  1. Assert: Type(tv) is Number.
  2. Assert: tv is not NaN.
  3. Let weekday be the Name of the entry in Table 52 with the Number WeekDay(tv).
  4. Let month be the Name of the entry in Table 53 with the Number MonthFromTime(tv).
  5. Let day be the String representation of DateFromTime(tv), formatted as a two-digit decimal number, padded to the left with the code unit 0x0030 (DIGIT ZERO) if necessary.
  6. Let yv be YearFromTime(tv).
  7. If yv+0𝔽, let yearSign be the empty String; otherwise, let yearSign be "-".
  8. Let year be the String representation of abs((yv)), formatted as a decimal number.
  9. Let paddedYear be ! StringPad(year, 4𝔽, "0", start).
  10. Return the string-concatenation of weekday, the code unit 0x0020 (SPACE), month, the code unit 0x0020 (SPACE), day, the code unit 0x0020 (SPACE), yearSign, and paddedYear.
Table 52: Names of days of the week
Number Name
+0𝔽 "Sun"
1𝔽 "Mon"
2𝔽 "Tue"
3𝔽 "Wed"
4𝔽 "Thu"
5𝔽 "Fri"
6𝔽 "Sat"
Table 53: Names of months of the year
Number Name
+0𝔽 "Jan"
1𝔽 "Feb"
2𝔽 "Mar"
3𝔽 "Apr"
4𝔽 "May"
5𝔽 "Jun"
6𝔽 "Jul"
7𝔽 "Aug"
8𝔽 "Sep"
9𝔽 "Oct"
10𝔽 "Nov"
11𝔽 "Dec"

21.4.4.41.3 TimeZoneString ( tv )

The abstract operation TimeZoneString takes argument tv. It performs the following steps when called:

  1. Assert: Type(tv) is Number.
  2. Assert: tv is not NaN.
  3. Let offset be LocalTZA(tv, true).
  4. If offset+0𝔽, then
    1. Let offsetSign be "+".
    2. Let absOffset be offset.
  5. Else,
    1. Let offsetSign be "-".
    2. Let absOffset be -offset.
  6. Let offsetMin be the String representation of MinFromTime(absOffset), formatted as a two-digit decimal number, padded to the left with the code unit 0x0030 (DIGIT ZERO) if necessary.
  7. Let offsetHour be the String representation of HourFromTime(absOffset), formatted as a two-digit decimal number, padded to the left with the code unit 0x0030 (DIGIT ZERO) if necessary.
  8. Let tzName be an implementation-defined string that is either the empty String or the string-concatenation of the code unit 0x0020 (SPACE), the code unit 0x0028 (LEFT PARENTHESIS), an implementation-defined timezone name, and the code unit 0x0029 (RIGHT PARENTHESIS).
  9. Return the string-concatenation of offsetSign, offsetHour, offsetMin, and tzName.

21.4.4.41.4 ToDateString ( tv )

The abstract operation ToDateString takes argument tv. It performs the following steps when called:

  1. Assert: Type(tv) is Number.
  2. If tv is NaN, return "Invalid Date".
  3. Let t be LocalTime(tv).
  4. Return the string-concatenation of DateString(t), the code unit 0x0020 (SPACE), TimeString(t), and TimeZoneString(tv).

21.4.4.42 Date.prototype.toTimeString ( )

The following steps are performed:

  1. Let O be this Date object.
  2. Let tv be ? thisTimeValue(O).
  3. If tv is NaN, return "Invalid Date".
  4. Let t be LocalTime(tv).
  5. Return the string-concatenation of TimeString(t) and TimeZoneString(tv).

21.4.4.43 Date.prototype.toUTCString ( )

The toUTCString method returns a String value representing the instance in time corresponding to this time value. The format of the String is based upon "HTTP-date" from RFC 7231, generalized to support the full range of times supported by ECMAScript Date objects. It performs the following steps when called:

  1. Let O be this Date object.
  2. Let tv be ? thisTimeValue(O).
  3. If tv is NaN, return "Invalid Date".
  4. Let weekday be the Name of the entry in Table 52 with the Number WeekDay(tv).
  5. Let month be the Name of the entry in Table 53 with the Number MonthFromTime(tv).
  6. Let day be the String representation of DateFromTime(tv), formatted as a two-digit decimal number, padded to the left with the code unit 0x0030 (DIGIT ZERO) if necessary.
  7. Let yv be YearFromTime(tv).
  8. If yv+0𝔽, let yearSign be the empty String; otherwise, let yearSign be "-".
  9. Let year be the String representation of abs((yv)), formatted as a decimal number.
  10. Let paddedYear be ! StringPad(year, 4𝔽, "0", start).
  11. Return the string-concatenation of weekday, ",", the code unit 0x0020 (SPACE), day, the code unit 0x0020 (SPACE), month, the code unit 0x0020 (SPACE), yearSign, paddedYear, the code unit 0x0020 (SPACE), and TimeString(tv).

21.4.4.44 Date.prototype.valueOf ( )

The following steps are performed:

  1. Return ? thisTimeValue(this value).

21.4.4.45 Date.prototype [ @@toPrimitive ] ( hint )

This function is called by ECMAScript language operators to convert a Date object to a primitive value. The allowed values for hint are "default", "number", and "string". Date objects, are unique among built-in ECMAScript object in that they treat "default" as being equivalent to "string", All other built-in ECMAScript objects treat "default" as being equivalent to "number".

When the @@toPrimitive method is called with argument hint, the following steps are taken:

  1. Let O be the this value.
  2. If Type(O) is not Object, throw a TypeError exception.
  3. If hint is "string" or "default", then
    1. Let tryFirst be string.
  4. Else if hint is "number", then
    1. Let tryFirst be number.
  5. Else, throw a TypeError exception.
  6. Return ? OrdinaryToPrimitive(O, tryFirst).

The value of the "name" property of this function is "[Symbol.toPrimitive]".

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.

21.4.5 Properties of Date Instances

Date instances are ordinary objects that inherit properties from the Date prototype object. Date instances also have a [[DateValue]] internal slot. The [[DateValue]] internal slot is the time value represented by this Date object.