Date.prototype.toISOString
Returns the date in ISO 8601 format in UTC.
Available since: ES5
Syntax
date.toISOString()Return value
stringA string like 2026-03-15T10:30:00.000Z in UTC.
Examples
A date in ISO:
const date = new Date(Date.UTC(2026, 2, 15, 10, 30));
console.log(date.toISOString());Output:
2026-03-15T10:30:00.000ZJust the date — the first 10 characters:
const date = new Date(Date.UTC(2026, 2, 15, 10, 30));
console.log(date.toISOString().slice(0, 10));Output:
2026-03-15Notes
The time is always converted to UTC (the Z at the end). For a user in another zone the date may be the neighbouring day: at 01:00 in Berlin it is still the previous day in UTC. This is how JSON.stringify() writes dates.
See also
- Date — A date and time: creating, reading parts, calculating.
- JSON.stringify — Converts a value to a JSON string.
- Date.prototype.toLocaleDateString — Formats a date without time by language rules.
Related recipes
In the tutorial
- Dates and time — The Date object in JavaScript: creating a date, reading the year, month and day, changing a date, the difference between dates and the ISO format.