Javascript countdown for specific time and date

后端 未结 3 1679
傲寒
傲寒 2020-12-29 17:41

I am using a jQuery plugin to put the countdown timer in my webpage. Currently the code that controls what the timer displays is:



        
3条回答
  •  春和景丽
    2020-12-29 18:25

    Get the current time, and note that this will be the time set on the users computer clock, whatever that is set to, and set a certain date, then calculate the difference and use that for the plugin:

    var date  = new Date(Date.UTC(2013, 8, 30, 12, 0, 0));
    var now   = new Date();
    var diff  = date.getTime()/1000 - now.getTime()/1000;
    
    var clock = $('.clock').FlipClock(diff, {
        clockFace: 'DailyCounter',
        countdown: true
    });
    

    For accurate times I would reccoment using your webserver to output the current time.

提交回复
热议问题