原型 - Date.toJSON() 方法
此方法将日期转换为 JSON 字符串(遵循 JSON 使用的 ISO 格式)。
语法
Date.toJSON();
返回值
返回给定日期的字符串。
示例
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
var str = new Date(1969, 11, 31, 19).toJSON();
alert ("Returns JSON String: " + str );
}
</script>
</head>
<body>
<p>Click the button to see the result.</p>
<br />
<br />
<input type = "button" value = "Result" onclick = "showResult();"/>
</body>
</html>
输出
prototype_json_tutorial.htm
广告