JS Built-ins
← Date11 / 120
Dateparsebeginner

Date.parse() β€” epoch string returns 0

πŸ“– Usage Example
Date.parse('2024-01-15T00:00:00.000Z')  // β†’ 1705276800000
Date.parse('invalid')  // β†’ NaN

Use Date.parse() to convert a date string into a millisecond timestamp, or detect invalid strings by checking for NaN.

Date.parse()

Parses a date string and returns the number of milliseconds since Unix epoch, or NaN if invalid.

Challenge: Verify that Date.parse('1970-01-01T00:00:00.000Z') returns 0.

πŸ’‘ Hints (1)
  • β€’ The Unix epoch is midnight Jan 1, 1970 UTC β€” its timestamp is exactly 0