Introduction
In JavaScript, we may wish to get a timestamp in milliseconds.
In this article, we'll look at how to get a timestamp in milliseconds in JavaScript.
How to get a timestamp in milliseconds in JavaScript
To get the timestamp in milliseconds since the Unix epoch, use Date.now()
method:
The Date.now() method returns the number of milliseconds elapsed since January 1, 1970.
Conclusion
To get a timestamp in milliseconds in JS we can use Date.now()
function.
If you want to get a timestamp in seconds simply divide Date.now()
value by 1000
.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}