How to use ToJSON in JavaScript
In this article I am going to explain about toISON() method in JavaScript.
JavaScript toJSON() Method
JavaScript toJSON() method also use for convert date object in string format but its use JSON format. JSON are same as like ISO format (YYYY-MM-DDTHH:mm:ss.sssZ).
Syntax
Example
<html>
<head>
<script type="text/javascript">
function myfun() {
var dd = new Date();
var mm = document.getElementById("tst");
mm.innerHTML = dd.toJSON();
}
</script>
</head>
<body>
<p>
click button to show Date</p>
<h1 id="tst" style="color: Blue" s>
</h1>
<button onclick="myfun()">
click me</button>
</body>
</html>
|
Output

You may also want to read these related articles: here
Ask Your Question
Got a programming related question? You may want to post your question here