Tutorial by Examples

performance.now() returns a precise timestamp: The number of milliseconds, including microseconds, since the current web page started to load. More generally, it returns the time elapsed since the performanceTiming.navigationStart event. t = performance.now(); For example, in a web browser's ma...
Date.now() returns the number of whole milliseconds that have elapsed since 1 January 1970 00:00:00 UTC. t = Date.now(); For example, Date.now() returns 1461069314 if it was called on 19 April 2016 at 12:35:14 GMT.
In older browsers where Date.now() is unavailable, use (new Date()).getTime() instead: t = (new Date()).getTime(); Or, to provide a Date.now() function for use in older browsers, use this polyfill: if (!Date.now) { Date.now = function now() { return new Date().getTime(); }; }
To get the timestamp in seconds Math.floor((new Date().getTime()) / 1000)

Page 1 of 1