constructor
Date.UTC
Returns the milliseconds since the Unix epoch for the given components interpreted as UTC. Unlike the Date component constructor, it does not apply the local timezone.
Date.UTC(year, month, day, hours, minutes, seconds, ms) Parameters
| Parameter | Purpose |
|---|---|
| year | full year (values 0-99 are treated as 1900+year) |
| month | 0-indexed month (Jan=0, Dec=11) |
| day | day of month 1-31 (default 1) |
| hours, minutes, seconds, ms | optional time components (default 0) |
Examples
console.log(Date.UTC(2026, 6, 19)); // 1784332800000 July 19 2026 UTC midnight
console.log(new Date(Date.UTC(2026, 0, 1)).toISOString()); // '2026-01-01T00:00:00.000Z' build a UTC Date
console.log(Date.UTC(2026, 11, 31, 23, 59, 59)); // last second of 2026 UTC month 11 = December
Gotcha
Month is 0-indexed just like the Date constructor; forgetting this shifts everything by one month.
Related
new Date()
Creates a Date object representing a single moment in time as milliseconds since the Unix epoch (1970-01-01T00:00:00Z). Called with no arguments it returns the current instant; with arguments it parses a timestamp, ISO string, or component parts.
Date.now
Returns the current time as an integer number of milliseconds since the Unix epoch without allocating a Date object. Use it for timestamps, expiry checks, and simple timing.
Date.prototype.getUTCFullYear / getUTCMonth / getUTCDate / getUTCHours
The UTC-flavored getters mirror their local counterparts but read fields in Coordinated Universal Time, ignoring the host timezone. Use them whenever you need timezone-stable output such as logs, database keys, or ISO output.