Date.prototype.toISOString()
The toISOString()
method returns a string in
simplified extended ISO format (ISO 8601), which is always 24 or 27
characters long
(YYYY-MM-DDTHH:mm:ss.sssZ
or
±YYYYYY-MM-DDTHH:mm:ss.sssZ
,
respectively). The timezone is always zero UTC offset, as denoted by the suffix
"Z
".
Syntax
toISOString()
Return value
A string representing the given date in the ISO 8601 format according to universal time.
Examples
Using toISOString()
let today = new Date('05 October 2011 14:48 UTC')
console.log(today.toISOString()) // Returns 2011-10-05T14:48:00.000Z
The above example uses parsing of a non–standard string value that may not be correctly parsed in non–Mozilla browsers.
Specifications
Specification |
---|
ECMAScript Language Specification # sec-date.prototype.toisostring |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
toISOString | ChromeFull support3 | EdgeFull support12 | FirefoxFull support1 | Internet ExplorerFull support9 | OperaFull support10.5 | SafariFull support5 | WebView AndroidFull support37 | Chrome AndroidFull support18 | Firefox for AndroidFull support4 | Opera AndroidFull support11 | Safari on iOSFull support4.2 | Samsung InternetFull support1.0 | DenoFull support1.0 | Node.jsFull support0.10.0 |
Legend
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.