utc
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.
date.getUTCFullYear() / getUTCMonth() / getUTCDate() / getUTCHours() Parameters
| Parameter | Purpose |
|---|---|
| getUTCFullYear() | 4-digit year in UTC |
| getUTCMonth() | 0-11 month in UTC (still zero-indexed!) |
| getUTCDate() | 1-31 day of month in UTC |
| getUTCHours() | 0-23 hour in UTC (also getUTCMinutes/Seconds/Milliseconds/Day) |
Examples
const d = new Date('2026-07-19T02:00:00Z');
console.log(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()); // 2026 6 19 month still 0-11
// UTC 22:00 on July 19 -> IST local is July 20
const d = new Date('2026-07-19T22:00:00Z');
console.log(d.getUTCDate(), '/', d.getDate()); // 19 / 20 UTC vs local can differ
const d = new Date('2026-07-19T23:59:59Z');
console.log(d.getUTCHours()); // 23 24-hour UTC
Gotcha
getUTCMonth is STILL 0-11 (the UTC prefix does not fix the indexing). Local and UTC values can differ by up to a day near midnight.
Related
Date.prototype.getFullYear
Returns the 4-digit year of the date according to LOCAL time. Prefer this over the deprecated getYear(), which returns year-1900.
Date.prototype.getTimezoneOffset
Returns the difference between UTC and the host's local time in MINUTES with the SIGN REVERSED from the conventional offset. So India (UTC+05:30) returns -330 and New York in EST (UTC-05:00) returns 300.
Date.prototype.toISOString
Returns the date as an ISO 8601 extended-format string in UTC, always ending in 'Z'. This is the canonical machine-readable serialization and the format most APIs and databases accept.