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

标签 javascript php html

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

相关文章:

php - 我丢失了 wordpress 密码。在数据库中,它已在用户表中加密。如何找回密码?

javascript - 在先前添加的元素之后插入新元素

javascript - 使用 Owl Carousel 将 slider 的滚动设置为仅 4 个元素?

javascript - Svelte.js 组件属性在带有 customElement : true 的脚本标记内未定义

PHP + winexe -> 永久加载

javascript - 事件委托(delegate) - 父元素目标而不是子元素

javascript - 通过单击复选框将一个文本框数据复制到另一个文本框中

javascript - 错误 : Syntax Error: Token ',' is an unexpected token

javascript - 未显示/使用 Google map 时出现控制台错误

javascript - 模态 Bootstrap 显示在所有窗口中,这是同一封电子邮件