flipclock.js resets on refresh after time expires

夙愿已清 提交于 2019-12-13 03:04:19

问题


I'm using Flipclock.js on a local page. Everything works fine, except after the countdown reaches 0. This page is used in a display in my office. I rotate between this an 2 other pages. Every time the page reloads after the timer reaches 0 the dates and time get screwy.

Here is the code:

var clocks = [];
        $(document).ready(function() {
            var currentDate = new Date();
            var futureDate  = new Date(currentDate.getFullYear() +0, 10, 14, 12, 31);
            var diff = futureDate.getTime() / 1000 - currentDate.getTime() / 1000;
            clocks.push($('.clock-1').FlipClock(diff, {
                clockFace: 'DailyCounter',
                countdown: true,
                showSeconds: false,
                callbacks: {
                    stop: function() {
                        $('.message-1').html('Insert message here!');
                    }
                }
}));

回答1:


Try to Use This Code This Is Working For Me

var clock;
$(document).ready(function() {
var currentDate = new Date();
var futureDate = new Date(2015,7,16,12,40,10); // (yyyy,m,d) //
var diff = futureDate.getTime() / 1000 - currentDate.getTime() / 1000;
var clock = $('.clock').FlipClock(diff, {
clockFace: 'DailyCounter',
countdown: true
});
});


来源:https://stackoverflow.com/questions/26935906/flipclock-js-resets-on-refresh-after-time-expires

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!