Javascript - Date toISOString() Method

The toISOString() method converts a Date object into a string, using the ISO-8601 standard.

Description

The toISOString() method converts a Date object into a string, using the ISO-8601 standard.

The format is: YYYY-MM-DDTHH:mm:ss.sssZ

Syntax

Date.toISOString()

Return

A String, representing the date and time using the ISO standard format

Example

Return a Date object as a String, using the ISO standard:

Demo

//display the date and time as a string, using the ISO standard.
var d = new Date();
var n = d.toISOString();
console.log(n);// www  .j av  a  2s.  c  o m

Result