0
votes

Using Keith Woods countdown timer.

Not sure how to set the countdown of the timer.

I have :

$('#count-down').countdown({
    until: new Date(2011, 2, 11, 10, 0, 0, 0),
    format: 'dHMS',
    timezone: 10,
    layout: '{d<}<span class="days">{dn} {dl}</span> {d>}<span class="hours">{hn} {hl}</span> <span class="minutes">{mn} {ml}</span> <span class="seconds">{snn} Seconds</span>',
    tickInterval: 1,
    serverSync: serverTime
  });

On the webpage the time displays:

2 Days 11 Hours 18 Minutes 21 Seconds

So not sure what I am doing wrong, as I suspect the 2011 ,2 , 10 denotes date ( but that is february and its March ) and not sure why its like this.

He does state on: http://keith-wood.name/countdown.html

A note on Date - the JavaScript Date constructor expects the year, month, and day as parameters. However, the month ranges from 0 to 11. To make explicit what date is intended (does a month of 3 mean March or April?) I specify the month from 1 to 12 and manually subtract the 1. Thus the following denotes 25 December, 2010.

$(selector).countdown({since: new Date(2010, 12-1, 25)});

So can anyone explain ?

Or am i being dense and March is 2nd month

2

2 Answers

2
votes

You answered your own question... The plugin uses 0 indexed months.

0 indexed months are great... and confusing

Jan = 0
Feb = 1
Mar = 2
...

March 11, 2011 is 2, 11, 2011

http://en.wikipedia.org/wiki/Zero-based_numbering

0
votes

It seems pretty explicitly explained in the text you have supplied. Javascript numbers months thus:

0 = January
1 = February
2 = March
3 = April
...
10 = November
11 = December

The date you have given is 2011, 2, 11 which is 11 March 2011. To make it more readable Keith has indicated that he uses subtraction of 1 from the month so it would read 2011, 3-1, 11 so you see a "3" which for most people will mean March. There's no magic here.