[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString [Back]  [Original]

Date.prototype.toISOString() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Date.prototype.toISOString()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..

toISOString() ISO ( ISO 8601), : YYYY-MM-DDTHH:mm:ss.sssZ. UTC, "Z".

In this article

dateObj.toISOString()

: toISOString()

js
var today = new Date("05 October 2011 14:48 UTC");

console.log(today.toISOString()); //  2011-10-05T14:48:00.000Z

, , Firefox.

ECMA-262 5- . , , :

js
if (!Date.prototype.toISOString) {
  (function () {
    function pad(number) {
      if (number < 10) {
        return "0" + number;
      }
      return number;
    }

    Date.prototype.toISOString = function () {
      return (
        this.getUTCFullYear() +
        "-" +
        pad(this.getUTCMonth() + 1) +
        "-" +
        pad(this.getUTCDate()) +
        "T" +
        pad(this.getUTCHours()) +
        ":" +
        pad(this.getUTCMinutes()) +
        ":" +
        pad(this.getUTCSeconds()) +
        "." +
        (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
        "Z"
      );
    };
  })();
}

Specification
ECMAScript 2027 LanguageSpecification
# sec-date.prototype.toisostring


Web Proxy Viewer  |  New URL  |  Original Page