Home » JavaScript Date toISOString() Method

JavaScript Date toISOString() Method

by Online Tutorials Library

JavaScript Date toISOString() method

The JavaScript date toISOString() method returns the string representation of the Date object. The returned string is in the form of simplified extended ISO format, which is always 24 or 27 characters long.

Syntax

The toISOString() method is represented by the following syntax:

Return

A Date object in the form of ISO string.

JavaScript Date toISOString() method example

Here, we will understand toISOString() method through various examples.

Example 1

Let’s see an example to fetch the current date in the form of ISO string.

Test it Now

Output:

2018-08-09T13:01:38.116Z  

Example 2

Let’s see an example to convert the specified Date object into the form of ISO string.

Test it Now

Output:

1947-08-15T14:52:10.000Z  
Next TopicJavaScript Date

You may also like