How to get milliseconds in Javascript
By FoxLearn 12/18/2024 6:45:55 AM 53
In JavaScript, you can get the current time in milliseconds using either `Date.now()` or the `getTime()` method of a `Date` object.
Both return the number of milliseconds since January 1, 1970, 00:00:00 UTC.
For example, Using Date.now()
:
let currentMilliseconds = Date.now(); console.log(currentMilliseconds);
For example, Using new Date()
and getTime()
:
let currentMilliseconds = new Date().getTime(); console.log(currentMilliseconds);
Both Date.now()
and getTime()
output the current time in milliseconds.
Categories
Popular Posts
Freedash bootstrap lite
11/13/2024
Dashboardkit Bootstrap
11/13/2024
Material Lite Admin Template
11/14/2024
Stisla Admin Dashboard Template
11/18/2024