Jump to content

Daily Countdown


joecooper

Recommended Posts

Im looking for some example code for countdowns.

 

I need to be able to count down to the same time each day for example 9PM each day.

 

and be displayed as 5hr 8m 15s.

 

When the timer runs out, then run some code then start again for the next day.

 

what would be the best route to take for this?

 

Thanks in advance

Link to comment
Share on other sites

I have a good one running now. just it uses the local system time. Im using the GMT-5 option but it relys on that the users time is correct.

 

OK, if you are going to have a timed-event occur on the server and you want the user's page to show a dynamic countdown to that event, then you should "prime" the JavaScript counter using data from the server. So, determine the GMT offset in the PHP code (i.e. server-side) and then use that to populate the offset as a JavaScript variable. Then use that variable in the JavaScript code to ensure the count-down is being calcualted using the correct time. Then the user's time setting does not impact the timer.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.