Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

clock countdown in php?

im looking for a code in php i have not been able to find it anywere

im looking for something like this ,

count down script,

if count down = 0

then " comand "

else

simple code but has been driving me crazy

4 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    I'm not sure what a countdown would do for you in php. You could use either the sleep() command (which words as sleep($number of seconds)) which pauses the code until the time has elapsed, but also a for cycle in case you want to execute stuff before the time has elapsed:

    for($i=0;$i<$maxsecondstime;$i++) {

    //code to do goes here

    sleep(1);//pause for a second

    }

    //code to do when countdown has elapsed goes here.

    Thing is, PHP is a server-side language and the point is to make it work faster, not slower - since it's activity is invisible to the visitor, he only sees the final result anyway. In order to have a clock countdown to do something for web visitors, I think you need some Javascript.

  • Anonymous
    5 years ago

    Thats javascript no longer own homestead page. Edit - gazing the code it seems such as you have copied that from yet another internet site incorrectly... in case your going to scouse borrow source, a minimum of have it working!

  • 1 decade ago

    $seconds = 5;

    while ($seconds > 0) {

    $seconds = $seconds - 1;

    sleep(1);

    }

    do_stuff();

    Source(s): PHP Developer
  • Anonymous
    1 decade ago

    Your probably looking for something like this, done in javascript :)

    http://www.hashemian.com/tools/javascript-countdow...

Still have questions? Get your answers by asking now.