How to Extract the Date from an ISO String in JavaScript?

Estimated read time 1 min read

In JavaScript, you can extract the date from an ISO string using the Date object. Here’s an example:

const isoString = "2022-06-08T09:30:00.000Z";

const date = new Date(isoString);

// Output: "Wed Jun 08 2022"

In this example, the Date object is constructed using the ISO string. The toDateString() method is then used to extract and format the date component of the Date object. This method returns a string representation of the date in the format “Weekday Month Day Year”.

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply