请有人向我解释一下这种情况。
我有以下代码:
<p>Click the button to display the date and time as a string, using the ISO standard.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo1"></p>
<p id="demo"></p>
<script>
function myFunction() {
var d = new Date();
var n = d.toISOString();
document.getElementById("demo1").innerHTML = d;
document.getElementById("demo").innerHTML = n;
}
</script>
Run Code Online (Sandbox Code Playgroud)
我得到以下结果:
Click the button to display the date and time as a string, using the ISO standard.
Try it
Mon Apr 06 2015 19:07:55 GMT+0100 (GMT Daylight Time)
2015-04-06T18:07:55.739Z
Run Code Online (Sandbox Code Playgroud)
为什么该toISOString()方法“需要”1 小时new …