Timestamps and Date Math
Compute differences and offsets between dates.
Timestamps
Internally a date is stored as a timestamp: the number of milliseconds since the Unix epoch, midnight on January 1, 1970, UTC.
const d = new Date("1970-01-01T00:00:00Z")
console.log(d.getTime())Date.now
Date.now returns the current timestamp in milliseconds without creating a Date object, which is efficient for measuring time.
const t = Date.now()
console.log(typeof t)
console.log(t > 0)All lessons in this course
- Creating and Reading Dates
- Timestamps and Date Math
- Formatting Dates
- Time Zones and UTC