Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery.final-countdown.js-需要帮助配置它吗_Javascript_Jquery_Jquery Plugins_Countdown_Jquery Countdown - Fatal编程技术网

Javascript jquery.final-countdown.js-需要帮助配置它吗

Javascript jquery.final-countdown.js-需要帮助配置它吗,javascript,jquery,jquery-plugins,countdown,jquery-countdown,Javascript,Jquery,Jquery Plugins,Countdown,Jquery Countdown,这里有配置(以及如何使用)此插件的说明: 初始化倒计时计时器,并在javascript中设置开始时间、结束时间和当前时间 $('倒计时')。最后的倒计时({ 开始:“1362139200”, 完:"1388461320",, 现在:'1387461319'}); 首先,我不知道这些数字是什么意思。。。甚至都没有解释。我推断他们的意思是秒 因此,我将代码设置为: $('.countdown').final_countdown({ 'start': 0, /* ((((Jan

这里有配置(以及如何使用)此插件的说明:

初始化倒计时计时器,并在javascript中设置开始时间、结束时间和当前时间

$('倒计时')。最后的倒计时({ 开始:“1362139200”, 完:"1388461320",, 现在:'1387461319'}); 首先,我不知道这些数字是什么意思。。。甚至都没有解释。我推断他们的意思是秒

因此,我将代码设置为:

    $('.countdown').final_countdown({
    'start':    0, /* ((((Jan + Feb + 3 days) * number of hours in a day) * number of minutes in an hour) * number of seconds in a minute) = total seconds */
    'end':      ((((31+28+31+2)*24)*60)*60), /* started at 9:25 pm on March 03 */
    'now':      ((((31+28+3)*24)*60)*60),
    seconds: {
        borderColor: '#8ef58e',
        borderWidth: '9'
    },
    minutes: {
        borderColor: '#ff8d72',
        borderWidth: '9'
    },
    hours: {
        borderColor: '#69ccff',
        borderWidth: '9'
    },
    days: {
        borderColor: '#ffd35c',
        borderWidth: '9'
    }
});
问题是,每次加载页面时,都会显示相同的29天。脚本没有获取当前时间/日期并与将来的另一个时间/日期进行比较

所以现在看起来还可以(29天),但几天后有人会加载这个页面,它将完全关闭

您可以在此处看到脚本(和问题):


我非常感谢您在这方面提供的帮助。

问题是您的“现在”值是一个固定值(例如
“现在”:((((31+28+3)*24)*60)*60),

相反,您应该使用JavaScript的本机
new Date()
动态获取“now”值,如下所示:

// We will get the "now" value from this variable
var today = new Date();

// My target date is this month 30th 9.25pm
var target = new Date(today);
target.setDate(30);
target.setHours(21,25,0,0);;

// Countdown start from yesterday
var yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);
yesterday.setHours(0,0,0,0);;

$('.countdown').final_countdown({
    'start': yesterday.getTime() / 1000,
        'end': target.getTime() / 1000,
        'now': today.getTime() / 1000,
    seconds: {
        borderColor: '#8ef58e',
        borderWidth: '9'
    },
    minutes: {
        borderColor: '#ff8d72',
        borderWidth: '9'
    },
    hours: {
        borderColor: '#69ccff',
        borderWidth: '9'
    },
    days: {
        borderColor: '#ffd35c',
        borderWidth: '9'
    }
});
工作示例请参考小提琴:

希望有帮助:)


$('document').ready(函数(){var end=Math.floor((新日期(“2018年11月2日”)).getTime()/1000);
var start=Math.floor((新日期(“2018年1月23日”).getTime()/1000);
var now=Math.floor((新日期).getTime()/1000);
$('倒计时')。最后的倒计时({
“开始”:开始,
“结束”:结束,
“现在”:现在
});
});

<script type="text/javascript">
        $('document').ready(function () { var end = Math.floor((new Date("02/11/2018")).getTime() / 1000);
            var start = Math.floor((new Date("01/23/2018")).getTime() / 1000);
            var now = Math.floor((new Date).getTime() / 1000);
            $('.countdown').final_countdown({
                'start': start,
                'end': end,
                'now': now

            });
      });