此方法将日期转换为 JSON 字符串(遵循 JSON 使用的 ISO 格式)。
语法
Date.toJSON();
返回值
返回给定日期的字符串。
例子
HTML
x
21
21
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
function showResult() {
8
var str = new Date(1969, 11, 31, 19).toJSON();
9
alert ("Returns JSON String: " + str );
10
}
11
</script>
12
</head>
13
14
<body>
15
<p>Click the button to see the result.</p>
16
<br />
17
18
<br />
19
<input type = "button" value = "Result" onclick = "showResult();"/>
20
</body>
21
</html>
阅读剩余 31%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8472.html