0

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

2 Answers 2

3

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/

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.