Date getTime() Method - Javascript Date

Javascript examples for Date:getTime

Description

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

Parameters

None

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>
<html>
<body>

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

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

<script>
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;
}
</script>

</body>
</html>

Related Tutorials