Javascript examples for Date:now
The now() method returns the number of milliseconds since January 1, 1970 00:00:00 UTC.
None
A Number, representing the number of milliseconds since midnight January 1, 1970
The following code shows how to use the number of milliseconds since 1970/01/01 to Calculate the number of years since 1970/01/01:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w. ja v a 2s . c o m*/ var minutes = 1000 * 60; var hours = minutes * 60; var days = hours * 24; var years = days * 365; var t = Date.now(); var y = Math.round(t / years); document.getElementById("demo").innerHTML = y; } </script> </body> </html>