toISOString() Method return a Date object as a String, using the ISO standard.
The standard is called ISO-8601 and the format is: YYYY-MM-DDTHH:mm:ss.sssZ
toISOString() |
Yes | 9.0 | Yes | Yes | Yes |
dateObject.toISOString();
None.
A string, representing the date and time using the ISO standard format.
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!-- www . j a v a2 s. c o m-->
var d = new Date();
var n = d.toISOString();
document.getElementById("demo").innerHTML = n;
}
</script>
</body>
</html>
The code above is rendered as follows: