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)