Home >>JavaScript Date Object Methods >JavaScript now() Method

JavaScript now() Method

JavaScript now() Method

JavaScript Date now() method is used to return the number of milliseconds passed since January 1, 1970 00:00:00 UTC. It is a static method of Date.

Syntax:
Date.now()

Browser Support

Method Chrome Edge Firefox Safari Opera
Date.now() Yes 9 Yes Yes Yes
Here is an example of JavaScript now() method:
<html>
<body>
<p>Click the button to see the Output.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() 
{
  var n = Date.now();
  document.getElementById("demo").innerHTML = n;
}
</script>
</body>
</html>
Output:

Click the button to see the Output.