Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

Date.UTC

Returns the timestamp of a date given in UTC.

Available since: ES1

Syntax

Date.UTC(year, monthIndex, day, hours, minutes, seconds)

Parameters

ParameterTypeDescription
year, monthIndex, …numberParts 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
12

Notes

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

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.

Thanks for reading!

Donate to the site — we work hard for you.