Date.UTC
Returns the timestamp of a date given in UTC.
Available since: ES1
Syntax
Date.UTC(year, monthIndex, day, hours, minutes, seconds)Parameters
| Parameter | Type | Description |
|---|---|---|
| year, monthIndex, … | number | Parts of the date in UTC; the month counts from zero. |
Return value
numberA timestamp in milliseconds.
Examples
A UTC date that does not depend on the computer's zone:
const date = new Date(Date.UTC(2026, 2, 15, 12, 0));
console.log(date.toISOString());
console.log(date.getUTCHours());Output:
2026-03-15T12:00:00.000Z
12Notes
new Date(2026, 2, 15) is local midnight, while new Date(Date.UTC(2026, 2, 15)) is UTC midnight. On servers and in tests UTC is easier to work with.
See also
- Date — A date and time: creating, reading parts, calculating.
- Date.prototype.toISOString — Returns the date in ISO 8601 format in UTC.
In the tutorial
- Dates and time — The Date object in JavaScript: creating a date, reading the year, month and day, changing a date, the difference between dates and the ISO format.