How would you do this? simple php/js question...

Marketcake

God of Leisure
Dec 6, 2009
450
8
0
Paradise
I always like brainstorming for ideas like this, just currently i don't know how to do this.

For the record I'll paypal someone to do this asap, like $10 or something. super easy script

Basically I need a countdown timer that counts down every 7 days and shows it on the homepage updating (not involving refreshes, but where it counts down on page).

It would show days/minutes/hours/seconds

When it reaches the end of the event for say... 5 hours or so, it would display a message "time has come!". at the end of that day it would reset the timer for another 7 days (always happens on tuesday at 3pm PST).

the problem is it must come from server time, not the persons desktop time which is what a lot of scripts online i have found do.

I found one that reads it from the server but it doesnt update continuously.

I thought of maybe doing this with PHP, where it uses time() and date() to read the server time, check if its after a certain day/time and then write it to a file.. then continuously check if that time is greater than or equal to the date in the file, but for it to be accurate it would have to run every minute which seems so redundant running 24/7

any clue?
 


Yeah, use PHP to output the server time into a javascript variable when the page is loaded. The rest can be done in javascript by manipulating elements on the page.
 
You could of course use pure javascript.
Gota love google : JavaScript Countdown/Count-up Timer/Clock/Ticker for Web Pages

(I like how the message in the tutorial resembles what the op wants to say)

I'm well aware of the powers of google. that script is based off the person's PC, not the server which if you will read isn't what I said in my op.

I actually found a good one I'm already using already. I could modify that one you posted to read strftime('%c'), except it still doesnt help with the fact that it needs to repeat every 7 days, so the date would have to be stored somewhere, and then compared, which I guess is where I'm stumped. I don't know if I can just use a textfile or something.
 
I'm well aware of the powers of google. that script is based off the person's PC, not the server which if you will read isn't what I said in my op.

I actually found a good one I'm already using already. I could modify that one you posted to read strftime('%c'), except it still doesnt help with the fact that it needs to repeat every 7 days, so the date would have to be stored somewhere, and then compared, which I guess is where I'm stumped. I don't know if I can just use a textfile or something.

Then load the time from PHP written into the javascript location duh , :D (and offset based on the timezone you want)
 
I had a similar problem with a countdown script, as depending on their location in the world, the countdown would only be from their clock to the time on the server.

I found a script on a site that counted down the same regardless of location and used that. I've attached it for you.

Use countdown.php within the browser to display the time left. Edit it according to the note in countdown. Very straight forward and counts down the same regardless of location.

I forget where i got it from, as it was a while ago, so apologies to the creator of this script. :)
 

Attachments

  • Like
Reactions: Marketcake
I had a similar problem with a countdown script, as depending on their location in the world, the countdown would only be from their clock to the time on the server.

I found a script on a site that counted down the same regardless of location and used that. I've attached it for you.

Use countdown.php within the browser to display the time left. Edit it according to the note in countdown. Very straight forward and counts down the same regardless of location.

I forget where i got it from, as it was a while ago, so apologies to the creator of this script. :)

oh shit, nice ! :) + Rep