var dayLength = 1000*3600*24;
var current = new Date();
console.log(current);
$('button').on('click', function(){
var a = new Date((new Date()).valueOf() + dayLength);
console.log(a);
});
var dayLength = 1000*3600*24;
var current = new Date();
console.log(current);
$('button').on('click', function(){
current = new Date(current.getTime() + dayLength);
console.log(current);
});
1条答案
按热度按时间py49o6xq1#
将
dayLength
添加到当前日期new Date()
。您应该将其添加到current
变量。个字符
请注意,我还将
valueOf
更改为getTime
,因为对于docs,通常不会在用户代码中调用valueOf
。