JS: Date.UTC

By Xah Lee. Date: . Last updated: .
Date.UTC(year, month)

Return a integer, that is the milliseconds representation of given year month of UTC.

The year and month arguments are required.

console.assert(Date.UTC(2026, 2) === 1772323200000);
// milliseconds start in 1970 Jan
console.assert(Date.UTC(1970, 0) === 0);
Date.UTC(year, month , date , hours , minutes , seconds , ms)

The parameters are exactly the same as the multiple number type parameters version of new Date(args), but interprets them as UTC.

🛑 WARNING: January is 0.

// 2026, Jan, 3rd
console.log(Date.UTC(2026, 0, 3));
// 1767398400000

console.log(new Date(1767398400000));
// 2026-01-03T00:00:00.000Z

🛑 WARNING: Date.UTC(), Date.UTC(string) return NaN

console.assert(isNaN(Date.UTC()));
console.assert(isNaN(Date.UTC("2026-02-03T14:48:15-0800")));

Convert milliseconds to a date object

// convert milliseconds to a date object
console.log(new Date(1772496000000));
// 2026-03-03T00:00:00.000Z

JavaScript. Date