Sometimes, we want to format fate as “yyyy-MM-dd’T’HH:mm:ss.SSS’Z’” with JavaScript.
In this article, we’ll look at how to format fate as “yyyy-MM-dd’T’HH:mm:ss.SSS’Z’” with JavaScript.
How to format fate as “yyyy-MM-dd’T’HH:mm:ss.SSS’Z’” with JavaScript?
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");
console.log(dt.toISOString());
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.
Conclusion
To format fate as “yyyy-MM-dd’T’HH:mm:ss.SSS’Z’” with JavaScript, we use the toISOString
method.