JS Built-ins
← Date75 / 120
DategetUTCMonthbeginner

getUTCMonth() β€” epoch month is 0

πŸ“– Usage Example
const d = new Date('2024-06-15T00:00:00.000Z')
d.getUTCMonth()  // β†’ 5 (June)
// 0=Jan, 11=Dec

Use getUTCMonth() to retrieve the zero-indexed UTC month (0 = January through 11 = December) of a Date.

Date.prototype.getUTCMonth()

The Unix epoch is January 1, 1970, so its UTC month is 0.

Challenge: Verify that new Date(0).getUTCMonth() returns 0.

πŸ’‘ Hints (1)
  • β€’ The epoch is January 1, 1970 UTC; January = month index 0