let day = queryResults[0].day;
//let day = 74
var current = new Date();
var followingDay =day + 24 hours ;
console.log(followingDay)
现在第一次是74天,我想得到74 + 1天,请帮助。
let day = queryResults[0].day;
//let day = 74
var current = new Date();
var followingDay =day + 24 hours ;
console.log(followingDay)
现在第一次是74天,我想得到74 + 1天,请帮助。
这是一个入门的示例,从本质上来说,JavaScript有点混乱:
We're essentially repeating ourselves considerably, we create a new Date (
now
), we then return a new date, calculated fromnow.getHours() + hours
.In addition to creating a new Date instance, we also use
now.setHours
to update the time using thegetHours
method.Whenever I begin to implement anything that deals with time and date, I always keep this video in my mind: https://www.youtube.com/watch?v=-5wpm-gesOY
这是一个电脑爱好者的视频,解释说有时(尤其是时间/日期),您可能会完成比原先想要的更多的工作。在大多数情况下,像Moment之类的库将为此类功能提供更丰富的API。