How to Convert Milliseconds into a Readable Date with JavaScript?

Sometimes, we want to convert milliseconds into a readable date with JavaScript.

In this article, we’ll look at how to convert milliseconds into a readable date with JavaScript.

Convert Milliseconds into a Readable Date with JavaScript

To convert milliseconds into a readable date with JavaScript, we can call the toLocaleString string method on the date.

For instance, we write:

const date = new Date(1324339200000);
const d = date.toLocaleString();
console.log(d)

We create a Date instance with the millisecond timestamp.

Then we call toLocaleString on the returned date object to return a string with the human readable version of the date-time assign it to d.

Therefore, d is '12/19/2011, 4:00:00 PM'.

Conclusion

To convert milliseconds into a readable date with JavaScript, we can call the toLocaleString string method on the date.