Categories
JavaScript Answers

How to convert ISO date to milliseconds in JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *