Get the number of milliseconds elapsed since 1 January 1970 00:00:00UTC

Get support on JavaScript,jQuery, AJAX and other related technology.
Post Reply
admin
Site Admin
Posts: 44

Get the number of milliseconds elapsed since 1 January 1970 00:00:00UTC

Post by admin » Sun May 17, 2020 8:16 pm

The static method Date.now returns the number of milliseconds that have elapsed since 1 January 1970 00:00:00
UTC. To get the number of milliseconds that have elapsed since that time using an instance of a Date object, use its
getTime method.

Code: Select all

// get milliseconds using static method now of Date
console.log(Date.now());

Code: Select all

// get milliseconds using method getTime of Date instance
console.log((new Date()).getTime());

Post Reply