代码示例:(标识:jsck_tojson)
<!DOCTYPE html>
<html>
<body>

<p>单击该按钮可将日期和时间显示为字符串,格式为 JSON 日期。</p>

<button onclick="myFunction()">试一试</button>

<p id="demo"></p>

<script>
function myFunction() {
  var d = new Date();
  var n = d.toJSON();
  document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>
运行结果: