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

← All JS Date methods · Math methods · Cron syntax