JS Built-ins
Datebeginner

Date Constructor β€” Unix epoch (0 ms)

πŸ“– Usage Example
const d1 = new Date()
const d2 = new Date('2024-01-15')
const d3 = new Date(2024, 0, 15)  // β†’ Jan 15 2024
d3 instanceof Date  // β†’ true

Use new Date() to create a Date object from the current time, a timestamp, a date string, or explicit year/month/day arguments.

Date Constructor

new Date(0) creates a Date at exactly the Unix epoch: January 1, 1970 00:00:00 UTC.

Challenge: Verify that new Date(0).getFullYear() returns 1970.

πŸ’‘ Hints (1)
  • β€’ Passing 0 to the Date constructor gives the Unix epoch (Jan 1 1970 UTC)