CKTIS / JavaScript
Date.UTC: UTC components to timestamp
Date.UTC interprets numeric components as UTC, normalizes them, and returns epoch milliseconds without creating a Date object.
Version: ECMAScript 1 onward; example target: Node.js 24.22.2
Syntax
Date.UTC(year, monthIndex?, date?, hours?, minutes?, seconds?, milliseconds?)Date.UTC(year, monthIndex?, date?, hours?, minutes?, seconds?, ms?) returns a Number of epoch milliseconds. monthIndex is zero-based; defaults are month 0, day 1, and zero for time fields. Years 0–99 are specially mapped to 1900–1999. The function returns a number, so create an object with new Date(Date.UTC(...)).
Values outside natural ranges are normalized: month 12 moves into January of the next year, and day 0 into the end of the previous month. After ToNumber and TimeClip, a non-finite value, missing required year, or result outside ±8.64e15 produces NaN. BigInt and Symbol throw TypeError.
As a static method, Date.UTC does not use the local time zone. Extra arguments are ignored, and the function is not a constructor. It has existed since ECMAScript 1.
Examples
const timestamp = Date.UTC(2024, 1, 29, 12, 30);
console.log(timestamp, new Date(timestamp).toISOString());
console.log(Date.UTC(2024, 12, 1) === Date.UTC(2025, 0, 1));
console.log(new Date(Date.UTC(99, 0, 1)).toISOString());
console.log(Number.isNaN(Date.UTC()));Result
1709209800000 2024-02-29T12:30:00.000Z true 1999-01-01T00:00:00.000Z true