joecooper Posted August 25, 2011 Share Posted August 25, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/245698-daily-countdown/ Share on other sites More sharing options...
joecooper Posted August 25, 2011 Author Share Posted August 25, 2011 I have realised that i should use JS for the count down, as it can display the time live. but then use another script for the end of countdown event... Quote Link to comment https://forums.phpfreaks.com/topic/245698-daily-countdown/#findComment-1261936 Share on other sites More sharing options...
WebStyles Posted August 25, 2011 Share Posted August 25, 2011 you can also use a little flash movie to do that. Bu yeah, js is the way to go for a live countdown if you don't want to include flash. Quote Link to comment https://forums.phpfreaks.com/topic/245698-daily-countdown/#findComment-1261963 Share on other sites More sharing options...
joecooper Posted August 25, 2011 Author Share Posted August 25, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/245698-daily-countdown/#findComment-1261981 Share on other sites More sharing options...
Psycho Posted August 25, 2011 Share Posted August 25, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/245698-daily-countdown/#findComment-1261988 Share on other sites More sharing options...
xyph Posted August 25, 2011 Share Posted August 25, 2011 And use Cron Jobs (nix) or Scheduled Tasks (win) to have a PHP script execute at a given time/interval. Quote Link to comment https://forums.phpfreaks.com/topic/245698-daily-countdown/#findComment-1262027 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.