English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript Date.now() method

 JavaScript Date Object

 The Date.now() method returns1970 years1month1Milliseconds past 00:00:00 UTC of the day.

Since now() is a static method of Date, you should always use it as Date.now().

Syntax:

Date.now()
var d = Date.now();
Test and see‹/›

Browser compatibility

The now() method is fully supported by all browsers:

Method
now()isisisisis

Technical Details

Return value:a number representing the1970 years1month1milliseconds since the start of the day at midnight
JavaScript Version:ECMAScript 5

More Examples

Calculate Execution Time:

//This example requires a delay2seconds can run
function myFunc() {
   var start = Date.now();
   document.getElementById('result').innerHTML = "starting timer..."
   setTimeout(function() {
       var millis = Date.now(); - start;
       document.getElementById('result').innerHTML = "seconds elapsed =" +
       Math.floor(millis/1000);
   }, 2000);
}
Test and see‹/›

 JavaScript Date Object