toISOString Method (Date) (JavaScript)

Returns a date as a string value in ISO format.

Syntax


objDate.toISOString()  

Return Value

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

Exceptions

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

Remarks

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

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

Example

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  

Requirements

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.

See Also

Date Object
Date and Time Strings