Date.UTC()
The same argument list as the multi-argument Date constructor, interpreted as UTC instead of local time. That single difference is the whole reason it exists.
Demo
The output is a plain number, which is the first thing to notice — Date.UTC does not return a Date. The epoch case gives 0, confirming the reference point. The month argument is zero-based exactly as getMonth is, so 2 means March. Out-of-range values roll rather than fail: month 12 becomes January of the next year, and day 0 becomes the last day of the previous month, which is the standard trick for finding a month length.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| year | number | yes | The full year. Values 0 to 99 are mapped to 1900–1999, which is a legacy trap. |
| month | number | yes | Zero-based, as everywhere in Date — 0 is January, 11 is December. Out-of-range values roll into the year. |
| day | number | no (1) | One-based day of the month. 0 means the last day of the previous month. Remaining arguments default to 0. |
Return value
number — A timestamp in milliseconds — NOT a Date. Wrap it in new Date() if you want an object.
Common patterns
const d = new Date(Date.UTC(2026, 2, 15));
const days = new Date(Date.UTC(y, m + 1, 0)).getUTCDate();
const fixed = new Date(Date.UTC(2026, 0, 1));
Examples
Pitfalls
Date.UTC(2026, 2, 15).toISOString()
new Date(Date.UTC(2026, 2, 15)).toISOString()
new Date(Date.UTC(2026, 3, 15)).toISOString().slice(0, 10)
new Date(Date.UTC(2026, 2, 15)).toISOString().slice(0, 10)
new Date(Date.UTC(26, 0, 1)).getUTCFullYear()
const d = new Date(0); d.setUTCFullYear(26); d.getUTCFullYear()
new Date(2026, 2, 15).toISOString()
new Date(Date.UTC(2026, 2, 15)).toISOString()
When to use
- Building a date from components without local-time interference
- Deterministic fixtures and tests
- Finding the number of days in a month, via day 0
- Server-side date construction
- You want a Date object → wrap the result
- You have an ISO string → new Date(string) or Date.parse
- You mean a local wall-clock time → the multi-argument constructor
- Years below 100 → set the year explicitly afterwards
Notes
FAQ
Because it predates any convenient way to say so, and it composes with the constructor instead — new Date(Date.UTC(...)). It is a small annoyance that has been in the language since 1997.
new Date(Date.UTC(2026, 2, 15));