View Full Version : Is this a job for PHP or JavaScript or Both??

10-23-2007, 12:38 AM
I need a Timer that counts down from 1hr, Once it gets to zero I need an event to happen (ex: output hello) then it will restart in an endless loop.

It thould be in the following format:


10-23-2007, 12:47 AM
JavaScript will allow you to count on a local computer's browser - so somebody will need to be viewing the page during the countdown for the event to occur. Javascript gives you power to do stuff on the client side. PHP gives you power to do stuff on the server side. If you need something to occur every hour regardless of who is looking at the site or how long they are, use a cron job with PHP.

It really depends on what the timer is linked to, what event you want to occur, and if its client or server side.

10-23-2007, 12:50 AM
yes, i want the event to happen even if nobody is on the site.
so i guess it is php

10-23-2007, 01:48 AM
I you just need something to happen once an hour, a cron job script could do this. Are you on a Linux server? If so, then you can write a PHP script and add it to your crontab to execute once an hour.

If you need the webpage to show an active count down, then you will need to do this using Javascript - when JS count down reaches 0 it will call a PHP script on your server to do something and then call the html web page again which will start the visable count down again.

10-23-2007, 10:15 PM
Here is a good introduction to cron jobs


If you aren't on Linux or have access to cron jobs, you can have pseudo cron jobs


10-24-2007, 03:15 AM
thanks for the help, I'm gonna look into it now :-)