Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. JavaScript
  3. Reference
  4. Standard built-in objects
  5. Date
  6. toISOString()

Date.prototype.toISOString()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

ThetoISOString() method ofDate instances returns a string representing this date in thedate time string format, asimplified format based onISO 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 UTC, as denoted by the suffixZ.

Try it

const event = new Date("05 October 2011 14:48 UTC");console.log(event.toString());// Expected output: "Wed Oct 05 2011 16:48:00 GMT+0200 (CEST)"// Note: your timezone may varyconsole.log(event.toISOString());// Expected output: "2011-10-05T14:48:00.000Z"

Syntax

js
toISOString()

Parameters

None.

Return value

A string representing the given date in thedate time string format according to universal time. It's the same format as the one required to be recognized byDate.parse().

Exceptions

RangeError

Thrown if the date isinvalid or if it corresponds to a year that cannot be represented in the date string format.

Examples

Using toISOString()

js
const d = new Date(0);console.log(d.toISOString()); // "1970-01-01T00:00:00.000Z"

Specifications

Specification
ECMAScript® 2026 Language Specification
# sec-date.prototype.toisostring

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp