JS Built-ins
← Date20 / 120
DateUTCintermediate

Date.UTC() β€” UTC month verification

πŸ“– Usage Example
Date.UTC(2024, 0, 15)  // β†’ 1705276800000
// month is 0-indexed
new Date(Date.UTC(2024, 0, 15)).toISOString()  // β†’ '2024-01-15T00:00:00.000Z'

Use Date.UTC() to compute the millisecond timestamp for a UTC date without constructing a Date object first.

Date.UTC()

When you pass Date.UTC(2024, 5, 15) to new Date(), the UTC month should be 5 (June).

Challenge: Verify that new Date(Date.UTC(2024, 5, 15)).getUTCMonth() returns 5.

πŸ’‘ Hints (1)
  • β€’ Date.UTC uses 0-indexed months; use getUTCMonth() (not getMonth()) to avoid timezone drift