小编Zid*_*rep的帖子

为什么 new.Date() 与 new.Date().toISOString() 相差 1 小时?

请有人向我解释一下这种情况。

我有以下代码:

<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 …

javascript methods datetime

4
推荐指数
1
解决办法
6161
查看次数

标签 统计

datetime ×1

javascript ×1

methods ×1