note 80371 deleted from function.date by derick

From: Date: Wed, 07 May 2008 18:17:05 +0000
Subject: note 80371 deleted from function.date by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-139145@lists.php.net to get a copy of this message
Note Submitter: SID TRIVEDI ---- <?php /************************************************************** * TITLE : Countdown to any particular date or event * * Credits : Louai Munajim * * Notes : Original script has been modified to * produce difference * * in seconds, it's more effective as well! * ***************************************************************/ //Any of following input can be retrieved by GET OR POST. //Input is set for New Year event. $year = '2008'; $month= '12'; $day = '31'; $hour = '00'; $minute = '00'; $second = '00'; //Countdown Function function countdown($year, $month, $day, $hour, $minute, $second) { global $return; global $countdown_date; $countdown_date = mktime($hour, $minute, $second, $month, $day, $year); $today = time(); $diff = $countdown_date - $today; if ($diff < 0)$diff = 0; $dl = floor($diff/60/60/24); $hl = floor(($diff - $dl*60*60*24)/60/60); $ml = floor(($diff - $dl*60*60*24 - $hl*60*60)/60); $sl = floor(($diff - $dl*60*60*24 - $hl*60*60 - $ml*60)); // OUTPUT echo "Today's date ".date("F j, Y, g:i:s A")."<br/>"; echo "Countdown date ".date("F j, Y, g:i:s A",$countdown_date)."<br/>"; echo "\n<br>"; $return = array($dl, $hl, $ml, $sl); return $return; } countdown($year, $month, $day, $hour, $minute, $second); list($dl,$hl,$ml,$sl) = $return; echo "Countdown ".$dl." days ".$hl." hours ".$ml." minutes ".$sl." seconds left"."\n<br>"; /* Above snippet produces following output: Today's date January 12, 2008, XX:XX:XX PM Countdown date December 31, 2008, 12:00:00 AM Countdown 353 days XX hours XX minutes XX seconds left */ ?>

« previous php.notes (#139145) next »