Hey All,
I have a browser based game , and it adds money to everyones account every half hour. So I need a script that will count down every half hour using the servers clock. So if its 11:06 in the server the counter would say "24m34s until next tick" Then after it reaches the 0m0s mark it restarts again at a half hour, but it has to be in sync with the servers clock or it just wouldn't make sense. Any help would be appreciated.
THanks
Countdown Script
Moderator: General Moderators
to be hoenst that didnt help me much, I have found many countdown scripts and its no big deal to setup a cron job to run the script, but whats the code to countdown every half hour and have the cron set so that when the cron runs it refreshes the counter. I am confused on all of that.
I am trying to display the countdown in the page.
I am trying to display the countdown in the page.
You don't write the script to count down, you let cron do it. You'd set up a cron job to run a script every 1/2 hour, then just have that script increment the values whenever it's called.
To determine the time left until the next increment, just determine the time left until the next 1/2 hour mark.
To determine the time left until the next increment, just determine the time left until the next 1/2 hour mark.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
I am not trying to increment a value, I am just trying to display in my website, a counter that starts from 30 minutes and goes down to 0 minutes, and its synced up with the system clock, so every half hour it will start over from 30 and work its way down to 0 and so on and so forth. So if the time is 11:22 it will be displaying "8m0s Till next Tick" once it hits 11:30 it will say "30m0s Till Next Tick"
Ok, so rather than checking against the database for some value that says the last time it was updated, just get the value of time() and compare it to the next 1/2 hour increment to see what's left.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
OOOOOHHHHH. Ok, now I get it.
Um... use Javascript? When the page loads initialize Javascript variable & then use JS to count down. I'm not sure how you'd do that exactly. There's bound to be tons of stuff regarding Javascript timers accessible through Google.
Um... use Javascript? When the page loads initialize Javascript variable & then use JS to count down. I'm not sure how you'd do that exactly. There's bound to be tons of stuff regarding Javascript timers accessible through Google.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.