1

I am using jQuery FlipClock to show a countdown timer for a given date time. So to show countdown timer with given date and time in FlipClock I got this link. In my case the end date is

8th December 2015, 12:0:0

So as per the link above I made my code like this

 var date  = new Date(Date.UTC(2015, 12, 8, 12, 0, 0));
            var now = new Date();
            var diff  = date.getTime()/1000 - now.getTime()/1000;
            var clock;
            clock = $('.clock').FlipClock({
                clockFace: 'DailyCounter',
                autoStart: false,
                callbacks: {
                    stop: function() {
                        $('.message').html('The clock has stopped!')
                    }
                }
            });
            clock.setTime(diff);
            clock.setCountdown(true);
            clock.start();

<div class="clock"></div>

But its showing countdown dates in wrong. So may I know why I am getting this error? How to solve the issue? Any suggestion or advice is really appreciable. Thanks

Here is my fiddle link

Community
  • 1
  • 1
NewUser
  • 12,713
  • 39
  • 142
  • 236

1 Answers1

0

The issue is because the month is zero based, in Date.UTC

 var date  = new Date(Date.UTC(2015, 11, 8, 12, 0, 0)); //11 for Dec

See the documentation (http://www.w3schools.com/jsref/jsref_utc.asp)

month : Required. An integer representing the month Expected values are 0-11, but other values are allowed:

-1 will result in the last month of the previous year

12 will result in the first month of the next year

13 will result in the second of the next year

Demo : http://jsfiddle.net/kishoresahas/cqgw1mb3/7

Kishore Sahasranaman
  • 4,013
  • 3
  • 24
  • 50