toJSON()
method return a Date object as a
String, formatted as a JSON date.
JSON dates have the same format as the ISO-8601 standard: YYYY-MM-DDTHH:mm:ss.sssZ
toJSON() |
Yes | 9.0 | Yes | Yes | Yes |
dateObject.toJSON()
None.
return a string representing the date and time formatted as a JSON date.
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from ww w .j a v a2 s . co m-->
var d = new Date();
var n = d.toJSON();
document.getElementById("demo").innerHTML = n;
}
</script>
</body>
</html>
The code above is rendered as follows: