gpt4 book ai didi

javascript - 如何设置倒计时器在 24 小时后结束

转载 作者:行者123 更新时间:2023-11-28 01:09:59 24 4
gpt4 key购买 nike

我想设置一个倒计时器在 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com