Date.prototype.toISOString()
Date.prototype.toISOString() is a JavaScript method in the Date category. Returns a string in ISO 8601 format. The syntax is date.toISOString(). A typical example: new Date().toISOString() // "2024-06-06T12:00:00.000Z". Another practical use — Format date for API: const now = new Date() const iso = now.toISOString() console.log(iso) // '2024-06-06T12:00:00.000Z' A close sibling is Date.now(), which returns the current timestamp in milliseconds. A close sibling is Date.parse(), which parses a date string and returns the timestamp. A close sibling is Date.UTC(), which returns the timestamp from UTC parameters. A close sibling is Date.prototype.getFullYear(), which returns the year (4 digits). More about this category: Date methods for working with dates and times. Related Date methods: Date.now(), Date.parse(), Date.UTC(), Date.prototype.getFullYear(), Date.prototype.getMonth(), Date.prototype.getDate(), Date.prototype.getDay(), Date.prototype.getHours(). This page is part of the free JS Reference documentation covering 1027+ methods, each with syntax, parameters, return values, examples, and common pitfalls.