new Date(2013, 2, 18)
is Mon Mar 18 2013 00:00:00 GMT+0100.
Months start counting in javascript at 0
, so use new Date(2013, 1, 18)
if you want february 18th :)
Question
I'm working with the countdown on this page http://chips.be-different.co.uk/
The countdown code (to 18th February) is:
$('#countdown').countdown({until: new Date(2013, 02, 18), format: 'DHMS', labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Mins', 'Secs'], labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Min', 'Sec'], expiryText: '', layout: '<div class="section"><div class="value">{dnn}</div><div class="label">{dl}</div></div><div class="section no-space"><div class="value">:</div></div><div class="section"><div class="value">{hnn}</div><div class="label">{hl}</div></div><div class="section no-space"><div class="value">:</div></div><div class="section"><div class="value">{mnn}</div><div class="label">{ml}</div></div><div class="section no-space"><div class="value">:</div></div><div class="section"><div class="value">{snn}</div><div class="label">{sl}</div></div>'});
yet it shows 68 days countdown, which is definitely not right!
Why is this?
Solution
new Date(2013, 2, 18)
is Mon Mar 18 2013 00:00:00 GMT+0100.
Months start counting in javascript at 0
, so use new Date(2013, 1, 18)
if you want february 18th :)
OTHER TIPS
Remember that months in Date
are 0 based, 0 = January. So it's correct