Home >>JavaScript Date Object Methods >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()
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
toISOString() | Yes | 9 | Yes | Yes | Yes |
<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>
Click the button to see the Output.