English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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().
Date.now()
var d = Date.now();Test and see‹/›
The now() method is fully supported by all browsers:
Method | |||||
now() | is | is | is | is | is |
Return value: | a number representing the1970 years1month1milliseconds since the start of the day at midnight |
---|---|
JavaScript Version: | ECMAScript 5 |
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‹/›