The getTime() Method

The internal clock in JavaScript starts at midnight January 1, 1970. The getTime() method returns the number of milliseconds since then:

HTML file: Displayed by browser:
<body>
<h4>Milliseconds since Jan 1, 1970:</h4>
<p id="demo"></p>
<script>
var d = new Date();
document.getElementById("demo").innerHTML = d.getTime();
</script>
</body>

Milliseconds since Jan 1, 1970:


BackTable of ContentsNext