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

JavaScript getTime() method

 JavaScript Date Object

getTime()returns from1970-1-1 milliseconds passed from 00:00:00 UTC (Coordinated Universal Time) to the date for1970-1-1 a negative value is returned for the time before 00:00:00 UTC.

getTime()The value returned by the method is the number of milliseconds since1970 years1Month1milliseconds since 00:00:00 of the day.

getTime()The method always uses UTC time to represent.getTime()will be the same as the client browser in other time zones.

Syntax:

date.getTime()
var d = new Date();
d.getTime();
Test and See‹/›

Browser Compatibility

getTime() method is fully supported by all browsers:

Method
getTime()YesYesYesYesYes

Technical Details

Return Value:UTC 1970 years1Month1Milliseconds since 00:00:00 UTC on the day
JavaScript Version:ECMAScript 1

More Examples

Calculate Execution Time:

function myFunc() {
   var end, start;
   start = new Date();
   for (var i = 0; i < 1000000; i++) {
   Math.sqrt(i);
   }
   end = new Date();
   var str = &39;Operation took &39; + (end.getTime() - start.getTime()) + ' msec';
}
Test and See‹/›

 JavaScript Date Object