Matt
Matt

Reputation: 2611

Jquery Countdown Date Format

Hi guys im using a jquery countdown, i want to set it to 16 hours but i cant for the life of me figure out the date format settings in the callback; can anyone help?

$(function () {
   var austDay = new Date();
   austDay = new Date(austDay.getFullYear() + 1, 0 - 1, 15);
   $('.time').countdown({until: austDay, 
   layout: '{dn} {dl}, {hn} {hl}, {mn} {ml}, and {sn} {sl}'});
   $('#year').text(austDay.getFullYear());  
});

It's configured in line 3 of the above code, here's a link to the plugin website.

Thanks in advance

Upvotes: 0

Views: 2736

Answers (2)

Prasenjit Kumar Nag
Prasenjit Kumar Nag

Reputation: 13461

You can set it to 16 hours from now using the following code

$(function () {
   var austDay = new Date();
   austDay.setHours(austDay.getHours() + 16);
   $('.time').countdown({until: austDay,                          
   layout: '{hn} {hl}, {mn} {ml}, and {sn} {sl}'});
   $('#year').text(austDay.getFullYear());  
});​

Or even better you can use the until option like follows

 $('.time').countdown({
     until: "16 hours",
     layout: '{hn} {hl}, {mn} {ml}, and {sn}    {sl}'
   });

but as you can see It's adding 16 hours to current date object it will be reset every time the page is reloaded. If you want it to persist you will have to build the object manually using date string.

Here is a working fiddle http://jsfiddle.net/joycse06/SDFLn/

Upvotes: 3

Aleksey Dr.
Aleksey Dr.

Reputation: 642

If you simple want have a countdown timer for 16 hours use build0in function

$('.time').countdown({until: +57600, layout: '{dn} {dl}, {hn} {hl}, {mn} {ml}, and {sn} {sl}'});

Where 57600 sec = 16 h

Upvotes: 2

Related Questions