Home >>JavaScript Date Object Methods >JavaScript toISOString() Method

JavaScript toISOString() Method

JavaScript toISOString() Method

JavaScript toISOString() method is used to convert a given Date object into a string using the ISO standard. This standard is called ISO-8601 and its format is: YYYY-MM-DDTHH:mm:ss.sssZ.

Syntax:
Date.toISOString()

Browser Support

Method Chrome Edge Firefox Safari Opera
toISOString() Yes 9 Yes Yes Yes
Here is an example of JavaScript toISOString() method:
<html>
<body>
<p>Click the button to see the Output.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction()
{
  var d = new Date();
  var n = d.toISOString();
  document.getElementById("demo").innerHTML = n;
}
</script>
</body>
</html>
Output:

Click the button to see the Output.


No Sidebar ads