JS Built-ins
← Date64 / 120
DategetTimeintermediate

getTime() β€” same date, same timestamp

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

Use getTime() to get the number of milliseconds elapsed since the Unix epoch (Jan 1, 1970 UTC).

Date.prototype.getTime()

Two Date objects created with the same value have equal timestamps.

Challenge: Verify that two dates created from the same string have the same getTime() value.

πŸ’‘ Hints (1)
  • β€’ getTime() lets you compare dates numerically β€” the same instant always yields the same ms value