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.
toISOString()
メソッドは、簡潔な拡張表記の ISO 形式 (ISO 8601) の文字列を返します。これは、常に 24 文字または 27 文字の長さになります(それぞれ、YYYY-MM-DDTHH:mm:ss.sssZ
または ±YYYYYY-MM-DDTHH:mm:ss.sssZ
)。タイムゾーンは常に 0 UTC オフセットになり、接尾辞 Z
で表記されます。
試してみましょう
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 vary
console.log(event.toISOString());
// Expected output: "2011-10-05T14:48:00.000Z"
構文
js
toISOString()
返値
協定世界時に基づき、与えられた日付を ISO 8601 形式で表す文字列。 Date.parse()
で認識するために必要な形式と同じ形式です。
例
toISOString() の使用
js
const today = new Date("05 October 2011 14:48 UTC");
console.log(today.toISOString()); // 2011-10-05T14:48:00.000Z を返す
上記の例は、Mozilla 以外のブラウザーでは正しく解析されない、非標準の文字列値を解析するのに使います。
仕様書
Specification |
---|
ECMAScript® 2025 Language Specification # sec-date.prototype.toisostring |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
toISOString |
Legend
Tip: you can click/tap on a cell for more information.
- 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.