Date.prototype.toISOString()

Returns the date as an ISO 8601 string in UTC.

Since ES5 Spec ↗

Syntax

date.toISOString()

Returns

string — A string like `YYYY-MM-DDTHH:mm:ss.sssZ` in UTC.

Throws

  • RangeError — The date is invalid.

Examples

const d = new Date(0);
console.log(d.toISOString());
Output
1970-01-01T00:00:00.000Z
const d = new Date("2026-05-15T12:30:00Z");
console.log(d.toISOString());
Output
2026-05-15T12:30:00.000Z

Notes

- Always expressed in UTC; the trailing `Z` denotes zero offset. - This is the format `JSON.stringify()` uses for dates. - The inverse is `new Date(isoString)` or `Date.parse()`.

Browser & runtime support

EnvironmentSince version
chrome 5
firefox 3.5
safari 4
edge 12
node 0.10

See also