Sometimes, we want to convert ISO date to milliseconds in JavaScript.
In this article, we’ll look at how to convert ISO date to milliseconds in JavaScript.
How to convert ISO date to milliseconds in JavaScript?
To convert ISO date to milliseconds in JavaScript, we can use the date’s getTime
method.
For instance, we write
const date = new Date("11/21/1987 16:00:00");
const milliseconds = date.getTime();
console.log(milliseconds);
to create a Date
object.
Then we call getTime
on it to get the timestamp in milliseconds.
Conclusion
To convert ISO date to milliseconds in JavaScript, we can use the date’s getTime
method.