JavaScript Date.prototype.toISOString() Method
The toISOString() method returns a date as a standard ISO 8601 string in UTC, such as 2026-11-28T00:30:00.000Z. It's the best format for storing and sending dates.
Description
The toISOString() method returns the date in the ISO 8601 format, always in UTC (shown by the trailing Z). This format is unambiguous, sorts correctly as text and is parsed reliably by every browser, so it's the right choice for APIs and storage. JSON.stringify() uses it for dates.
Taking the first 10 characters gives a YYYY-MM-DD date, but remember it's the UTC date, which can differ from the local date near midnight.
To get a YYYY-MM-DD date in the user's own time zone, build it from getFullYear(), getMonth() and getDate() with padStart(), or use toLocaleDateString('sv-SE'), whose format happens to match. When reading the string back, new Date(isoString) recreates the exact moment.
Syntax
date.toISOString()Return Value
A string in the ISO 8601 format YYYY-MM-DDTHH:mm:ss.sssZ, in UTC.
Exceptions
- RangeErrorThrown if the date is invalid.
Example
Browser Support
The following information will show you the current browser support for the Date.prototype.toISOString() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





