Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count down from a particular date using flipclock.js

I am using http://flipclockjs.com/

This is my call script so far,

<script type="text/javascript">
var clock = $('.clock').FlipClock(3600 * 24 * 5, {
    clockFace: 'DailyCounter',
    countdown: true,
});
</script>

Please could someone tell me how i can count down from an exact date?

So for example the date is 21st July, 2014 in UK time, and everyone that visits that site will see how long there is remaining till that date based on the current date.

like image 653
Third_Hyperion Avatar asked Jul 16 '14 16:07

Third_Hyperion


1 Answers

@Matt, Great example, however I can see why "coolshrimp" posted a similar formula, both are half correct.

In my website, when i use jsfiddle, I want it to also show "Hours" "Minutes" and "Seconds", the following example worked perfectly for me:

    <script type="text/javascript">
        var date = new Date("February 01, 2016 02:15:00"); //Month Days, Year HH:MM:SS
        var now = new Date();
        var diff = (date.getTime()/1000) - (now.getTime()/1000);

        var clock = $('.clock').FlipClock(diff,{
            clockFace: 'DailyCounter',
            countdown: true
        });
    </script>
like image 132
Burgo855 Avatar answered Oct 10 '22 17:10

Burgo855