Countdown timers

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.

Many thanks.

Dez

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.

Why would you even want counter in PHP? As guido said, it’s pointless.

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.

That is not a good reason why you want to do it in PHP. Do it in Javascript.

It’s a good enough reason for me. Anyone know how to do it in PHP ?

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" >

You don’t use php for such thing, you use Javascript as guido mentioned already.

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

Exactly! :cool:

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)

ok, thanks for the input, I’ll rethink this a little more. I was trying to avoid js, because some people have it disabled.

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.

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 ?

With jQuery you could use a plugin like this:
http://keith-wood.name/countdown.html

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.

if you google something like “countdown timer javascript” you will get a truck load of hits.

if you post your code we can try to help you get it going if you get stuck.