Re: Count down

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 22 Sep 2003, Frank McIsaac wrote:

>         Hi all.  I was wanting to make a page that takes a set date and
> counts down to zero displaying days, minutes, and seconds.  Basically, I
> want it to count down from the current date and time until a future date
> and time is reached (ie.  Sept. 30th is x days, y minutes, and z seconds
> away from right now).  Is this possible?  If so, how.  Thanks for the
> help.

 $futuretime = strtotime("9/30/2003 12:00:00");

 $difftime = $futuretime - time();

 $days = (int)($difftime/86400);
 $leftover = $difftime%86400;
 $minutes = (int)($leftover/1440);
 $leftover = $leftover%1440;
 $seconds = $leftover;

 printf("Future Time is %d day%s, %d minute%s, and %d second%s away from
 now.", $days, $days==1?"":"s",
        $minutes, $minutes==1?"":"s",
        $seconds, $seconds==1?"":"s");

Beckman
---------------------------------------------------------------------------
Peter Beckman                                                  Internet Guy
beckman@purplecow.com                             http://www.purplecow.com/
---------------------------------------------------------------------------
-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux