Parse a JSON Date in JavaScript

To parse a JSON date:

  1. Use the toJSON() method to get a string representation of the Date object.

  2. Pass the JSON string to the Date() constructor.

  3. The Date() constructor will parse the ISO string and create a Date objec

const json = new Date().toJSON();

console.log(json); // 👉️ "2022-01-23T09:04:45.904Z"

const date = new Date(json);

console.log(date); // 👉️ Sun Jan 23 2022 11:04:45

Last updated