|
I found a code that shows the result I want in the field:
global $return;
//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
$return = array($dl, $hl, $ml, $sl);
return $return;
} countdown($year, $month, $day, $hour, $minute, $second);
list($dl,$hl,$ml,$sl) = $return;
$value= "Countdown ".$dl." days ".$hl." hours ".$ml." minutes ".$sl." seconds left"."\n<br>"; I now only need to replace the countdown variable with my fieldname: BidCloseDate I've tried the following but it returns 0 days 0 months... Where am I going wrong?
global $return;
//Any of following input can be retrieved by GET OR POST.
//Input is set for New Year event.
$start=("BidCloseDate");
//Countdown Function
function countdown($start)
{
global $return;
global $countdown_date;
$countdown_date = mktime($start);
$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
$return = array($dl, $hl, $ml, $sl);
return $return;
} countdown($start);
list($dl,$hl,$ml,$sl) = $return;
$value= "Countdown ".$dl." days ".$hl." hours ".$ml." minutes ".$sl." seconds left"."\n<br>";
|