looking for a continous countdown script using server crons.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
2DaysAway
Forum Newbie
Posts: 8
Joined: Thu Oct 18, 2007 4:35 pm

looking for a continous countdown script using server crons.

Post by 2DaysAway »

I own a game where I use php crons to update game ranks every five minutes and issue turns every ten minutes. These work fine. What happens though when you view a ranks page the time stops. I would like to see the time to continue to run down. I'm wondering if there is a script that could implement this. I'm thinking a javascript using the server crons.

Any ideas or is this a lost cause?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Yes, you could feed the current time to a javascript function and let it count down for you. However, as javascript is client side and php (and the cron executing the php scripts) are server side, the javascript countdown would not be dead on accurate. It would only provide an idea of how much time would be left.

Another idea would be an AJAX script to pull the time every (x) seconds. This is a much better idea, as it will be guaranteed to be accurate, since it is pulling data straight from the server. However, since you're running these scripts on cron jobs, you may be concerned about server load? If you're not concerned about server load, go with the AJAX. Otherwise, javascript.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply