Name

Date.now() — return the current time in milliseconds

Availability

ECMAScript 5

Synopsis

Date.now()

Returns

The current time, in milliseconds since midnight GMT on January 1, 1970.

Description

Prior to ECMAScript 5, you can implement this method like this:

Date.now = function() { return (new Date()).getTime(); }

Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.