我想设置一个倒计时器在 24 小时后结束。这是迄今为止我用于计时器的代码:
countdown: {
// Possible options are 'default' or 'piechart'
type: 'default',
// The date when the countdown started. Used by the progress bars. 24 Hour format (00 to 23): Month Day, Year Hours:Minutes
startDate: new Date(),
// The target date we're counting down to. 24 Hour format (00 to 23): Month Day, Year Hours:Minutes
targetDate: new Date("startDate"+1)
},
最初,模板附带的代码是;
countdown: {
// Possible options are 'default' or 'piechart'
type: 'default',
// The date when the countdown started. Used by the progress bars. 24 Hour format (00 to 23): Month Day, Year Hours:Minutes
startDate: new Date("November 1, 2013 00:00"),
// The target date we're counting down to. 24 Hour format (00 to 23): Month Day, Year Hours:Minutes
targetDate: new Date("July 20, 2014 11:13")
},
我希望倒计时每天开始并在 24 小时后结束,这就是我删除开始日期的原因。任何帮助,将不胜感激。谢谢。
最佳答案
var startDate = new Date();
var endDate = new Date();
endDate.setDate(startDate.getDate() + 1);
var countdown = { startDate: startDate, targetDate: endDate };
关于javascript - 如何设置倒计时器在 24 小时后结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24570485/