改变倒计时持续时间

时间:2013-01-23 12:54:30

标签: javascript jquery jquery-countdown

我在我的网站上使用此倒计时,here

您可以查看脚本here(太大而无法发布)

这是头部的代码:

<script type="text/javascript" src="javascripts/jquery.countdown.js"></script>
    <script type="text/javascript">
        $(function () {
            var austDay = new Date();
            austDay = new Date(austDay.getFullYear() + 1, 1 - 1, 26);
            $('.countdown-container').countdown({until: austDay});
            $('#year').text(austDay.getFullYear());
        });
    </script>

我希望能够改变倒计时持续时间,希望能够改变我想要的时间。

如果有人能提供洞察力,那就太棒了。

2 个答案:

答案 0 :(得分:1)

编辑:

var CommingDate = new Date(); 
CommingDate= new Date(CommingDate.getFullYear() + 1, 1 - 1, 26);

解释

Date( CommingDate.getFullYear()+ 1 , 1 - 1, 26); 意味着您希望将当前年份增加1

Date(CommingDate.getFullYear() + 1, 1 - 1 , 26);

第一个号码将在一个月内前进,所以如果你要做2 - 1这个月将是2月

但如果您要执行1 - 1之类的操作,这将导致获得当前月份 Date(CommingDate.getFullYear() + 1, 1 - 1, 26 ); 最后一个数字26将是您想要的那一天

答案 1 :(得分:1)

我有同样的问题,但侯赛因的解释帮助我解决了这个问题。

例如,如果您想倒计时到25.10.2017,则代码应为

Date(CommingDate.getFullYear() + 1, 10 - 1, 25);

,其中

CommingDate.getFullYear()+ 1 - 它的2017年(实际年份+ 1)

10 - 1 - 这个月

25 - 这一天

相关问题