JS Built-ins
← Date10 / 120
Datenowintermediate

Date.now() β€” consistent with new Date().getTime()

πŸ“– Usage Example
const ts = Date.now()  // e.g. 1705276800000
typeof ts  // β†’ 'number'

Use Date.now() to get the current time as milliseconds since the Unix epoch without creating a Date object.

Date.now()

Date.now() is equivalent to new Date().getTime(). Both return the same kind of value.

Challenge: Verify that typeof Date.now() === typeof new Date(0).getTime().

πŸ’‘ Hints (1)
  • β€’ Date.now() is the preferred static shorthand β€” same result as new Date().getTime()