Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

toISOString Method (Date) (JavaScript)

Returns a date as a string value in ISO format.

objDate.toISOString()

A string representation of the date in International Organization for Standardization (ISO) format.

If objDate does not contain a valid date, a RangeError exception is thrown.

The ISO format is a simplification of the ISO 8601 format. For more information, see Date and Time Strings (JavaScript).

The time zone is always UTC, denoted by the suffix Z in the output.

The following example illustrates the use of the toISOString method.

var dt = new Date("30 July 2010 15:05 UTC");
document.write(dt.toISOString());
document.write("<br />");
document.write(dt.toUTCString());

// Output:
//  2010-07-30T15:05:00.000Z
//  Fri, 30 Jul 2010 15:05:00 UTC

Supported in the following document modes: Internet Explorer 9 standards, Internet Explorer 10 standards, and Internet Explorer 11 standards. Also supported in Store apps (Windows 8 and Windows Phone 8.1). See Version Information. Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft