Date.UTC() method accepts parameters similar to the
Date constructor, but treats them as UTC. It returns the number of milliseconds since January 1, 1970, 00:00:00 UTC.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
ECMAScript 2017 and later:
Date.UTC(year[, month[, day[, hour[, minute[, second[, millisecond]]]]]])
ECMAScript 2016 and earlier: (
month used to be required)
Date.UTC(year, month[, day[, hour[, minute[, second[, millisecond]]]]])
- A full year.
- An integer between 0 (January) and 11 (December) representing the month. (Up through ECMAScript 2016,
monthwas a required parameter. As of ES2017, it no longer is.)
- Optional. An integer between 1 and 31 representing the day of the month. If omitted, defaults to 1.
- An integer between 0 and 23 representing the hours. If omitted, defaults to 0.
- An integer between 0 and 59 representing the minutes. If omitted, defaults to 0.
- An integer between 0 and 59 representing the seconds. If omitted, defaults to 0.
- An integer between 0 and 999 representing the milliseconds. If omitted, defaults to 0.
A number representing the number of milliseconds for the given date since January 1, 1970, 00:00:00, UTC.
UTC() takes comma-delimited date and time parameters and returns the number of milliseconds between January 1, 1970, 00:00:00, universal time and the specified date and time.
Years between 0 and 99 are converted to a year in the 20th century
(1900 + year); for example, 95 is converted to the year 1995.
UTC() method differs from the
Date constructor in two ways.
Date.UTC()uses universal time instead of the local time.
Date.UTC()returns a time value as a number instead of creating a
If a parameter is outside of the expected range, the
UTC() method updates the other parameters to accommodate the value. For example, if 15 is used for month, the year will be incremented by 1
(year + 1) and 3 will be used for the month.
The following statement creates a
Date object with the arguments treated as UTC instead of local:
var utcDate = new Date(Date.UTC(2018, 11, 1, 0, 0, 0));
|ECMAScript Latest Draft (ECMA-262)
The definition of 'Date.UTC' in that specification.
|Chrome Full support 1||Edge Full support 12||Firefox Full support 1||IE Full support 3||Opera Full support Yes||Safari Full support 1||WebView Android Full support 1||Chrome Android Full support 18||Firefox Android Full support 4||Opera Android Full support Yes||Safari iOS Full support 1||Samsung Internet Android Full support 1.0||nodejs Full support Yes|
- Full support
- Full support
Date.UTC with fewer than two arguments
Date.UTC(); Date.UTC(1); // Safari: NaN // Chrome/Opera/V8: NaN // Firefox <54: non-NaN // Firefox 54+: NaN // IE: non-NaN // Edge: NaN