I have a script to count the time a ticket is open each day, but only for hours we are open. The details of the functions arent that important but i have pasted it all here as it may be the cause for the failure.
Heres the function:
function getTime($o, $now, $total) {
//One Day in seconds
$oneDay = 86400;
//One Business day (12 hours, 7am-7pm)
$oneBDay = 43200;
//Get the timestamp of 7am/7pm for time given
$sevenAM = mktime('7', '0', '0', m($o), d($o), y($o));
$sevenPM = mktime('19', '0', '0', m($o), d($o), y($o));
//If Ticket Start Time is before 7am, we only count from 7am after
if ($o < $sevenAM) {
$o = $sevenAM;
} else {
$o = $o;
}
//Debug to get today
$today = date('Y-m-d h:i:s a', $o);
//See if we are within the same business day
$diff = $now - $o;
//Debug
//echo $today.",".$timeSpent.",".$total."
";
//If we are not within 1 business day, do this again
if ($diff > $oneBDay) {
//Total Time spent for the day
$timeSpent = $sevenPM - $o;
//Add todays time to total time
$total = $total + $timeSpent;
//Move to tomorrow
$o = $sevenAM + $oneDay;
getTime($o, $now, $total);
}
//If we are within 1 business day, count the time for today and return our result
if ($diff < $oneBDay) {
$time = $diff;
$total = $total + $time; //for example $total = 123456
return $total;
}
}
when I do
echo getTime($o,$now,0);
I would expect to see 123456. But i get nothing printed.
The function runs and I know total has a value ( I have set it statically as a debug).
--Note the function calls itself if needed
additional functions:
function y($o){
$y = date('Y',$o);
return $y;
}
function m($o){
$m = date('m',$o);
return $m;
}
function d($o){
$d = date('d',$o);
return $d;
}
EDIT:
if i do :
if ($diff < $oneBDay) {
$time = $diff;
$total = $total + $time; //for example $total = 123456
echo "My Total:".$total;
return $total;
}
I will see My Total:123456