小编Har*_*nis的帖子

Javascript getTime() 返回与时间对象本身不同的时间

Javascript getTime() 返回与时间对象本身不同的时间。

function doTime(){
  var data = [];
  var newDate = new Date('2020-01-01');

  for (var i = 0; i < 10; i++) {
    newDate.setTime(newDate.getTime() + (1000 * 60 * 60));
    console.log(newDate);                //<<----these times are not the same for some reason, why?
    data.push({'date': newDate});        //<<----these times are not the same for some reason, why?
    }
  console.log(data);
  }
Run Code Online (Sandbox Code Playgroud)

还有输出!!

Wed Jan 01 2020 03:00:00 GMT+0200 (Eastern European Standard Time)
Wed Jan 01 2020 04:00:00 GMT+0200 (Eastern European Standard Time)
Wed Jan …
Run Code Online (Sandbox Code Playgroud)

javascript date gettime

0
推荐指数
1
解决办法
43
查看次数

标签 统计

date ×1

gettime ×1

javascript ×1