JavaScript Answers

How to format fate as “yyyy-MM-dd’T’HH:mm:ss.SSS’Z'” with JavaScript?

Spread the love

To format fate as "yyyy-MM-dd’T’HH:mm:ss.SSS’Z’" with JavaScript, we use the toISOString method.

For instance, we write

const dt = new Date("30 July 2022 15:05 UTC");

to create a new Date object.

Then we call toISOString on it to return a date time string in the "yyyy-MM-dd’T’HH:mm:ss.SSS’Z’" format.

By John Au-Yeung

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

Leave a Reply

Your email address will not be published.