Date getTime() Method - Javascript Date

Javascript examples for Date:getTime


The getTime() method returns the number of milliseconds between midnight of January 1, 1970 and the specified date.



Return Value:

A Number, representing the number of milliseconds since midnight January 1, 1970

The following code shows how to return the number of milliseconds since 1970/01/01:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {//from w  ww.  j  a  v a 2  s .  co  m
    var d = new Date();
    var n = d.getTimezoneOffset();
    document.getElementById("demo").innerHTML = n;


Related Tutorials