JavaScript toISOString() | Get the Date as String based on ISO Standard

The JavaScript toISOString() method is used to get the date as a string based on the ISO (International Organization for Standardization) standard. For example:

HTML with JavaScript Code
<!DOCTYPE html>
   <p id="xyz"></p>

      const d = new Date();
      let dateISO = d.toISOString();
      document.getElementById("xyz").innerHTML = dateISO;


Please note: The ISO date format is YYYY-MM-DDTHH:mm:ss.sssZ where:

JavaScript toISOString() Syntax

The syntax of toISOString() method in JavaScript is:


where x must be an object of the Date() constructor.

The toISOString() method returns a string representing both the date and the time based on ISO standard.

JavaScript Online Test

« Previous Tutorial Next Tutorial »

Liked this article? Share it!

Like/follow us on social media for updates!