dez — 2010-12-02T15:34:57-05:00 — #1
Have gone all over the net looking but can't seem to find a simple php code to just countdown to 4pm every Wednesday for example. All I seem to find, is for yearly events like birthdays. Can anyone help please? Pure PHP and no js.
guido2004 — 2010-12-02T15:41:29-05:00 — #2
Countdown how? Where? Like a clock in your browser? You can't do that with PHP. You could in theory do continuous AJAX calls (but that's JS) or autorefresh the page, but that makes little sense.
blue1 — 2010-12-02T15:46:13-05:00 — #3
Why would you even want counter in PHP? As guido said, it's pointless.
dez — 2010-12-02T15:50:42-05:00 — #4
Lots of very good reasons, but this particular one, is so that there's a countdown on a website page, to 4pm every Wednesday, then, when that time is reached, it counts down again to the next Wednesday 4pm, in days, hours and minutes.
Amy help appreciated.
guido2004 — 2010-12-02T15:52:51-05:00 — #5
dez — 2010-12-02T15:57:46-05:00 — #6
It's a good enough reason for me. Anyone know how to do it in PHP ?
guido2004 — 2010-12-02T16:03:30-05:00 — #7
You CAN'T do it in PHP. PHP is server side. Your webpage is shown clientside.
You can't use AJAX because it uses JS as well.
So you might try with something like:
<meta http-equiv="refresh" content="5" >
blue1 — 2010-12-02T16:04:34-05:00 — #8
scallioxtx — 2010-12-02T16:13:09-05:00 — #9
gimme a J, gimme an A, gimme a V, gimme an A, gimme an S, gimme a C, gimme an R, gimme an I, gimme a P, gimme a T !
What do you get?
J A V A S C R I P T
system — 2010-12-02T16:26:48-05:00 — #10
With a PHP timer, on page load at best all you will get is the time left to a date/time in the future but it will not continue to count down the time after the page has loaded.
If you want the timer to continue counting down after the page has loaded then you will have to use JAVA (f'ing) SCRIPT (excuse my french ) in either plain vanilla flavour or AJAX (which would be pointless imho)
dez — 2010-12-02T16:32:18-05:00 — #11
ok, thanks for the input, I'll rethink this a little more. I was trying to avoid js, because some people have it disabled.
wonshikee — 2010-12-02T16:52:57-05:00 — #12
The question is, do you need the physical timer to actually tick down, or just display the time till wed on page load once.
I believe everyone is assuming the former, thus you would need js to do it properly.
dez — 2010-12-02T17:07:30-05:00 — #13
Yep, the former, to tick down while on the site.
If it has to be done with js, what's the leanest way to do it please ?
immerse — 2010-12-02T17:12:45-05:00 — #14
With jQuery you could use a plugin like this:
If you don't want to use jQuery, then maybe a library like DateJS might help.
Writing your own solution might be the leanest way to do it, but it'll require quite a bit of coding.
system — 2010-12-02T17:20:34-05:00 — #15
if you post your code we can try to help you get it going if you get stuck.