JS Built-ins
← Date98 / 120
DatetoISOStringbeginner

toISOString() β€” ends with "Z"

πŸ“– Usage Example
const d = new Date('2024-01-15T00:00:00.000Z')
d.toISOString()  // β†’ '2024-01-15T00:00:00.000Z'

Use toISOString() to serialize a Date as a UTC ISO 8601 string in the format YYYY-MM-DDTHH:mm:ss.sssZ.

Date.prototype.toISOString()

The output always ends with "Z" to indicate UTC time.

Challenge: Verify that new Date(0).toISOString().endsWith('Z') is true.

πŸ’‘ Hints (1)
  • β€’ "Z" in an ISO string means UTC (Zulu time)