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.