function date_diff($str_start, $str_end)
{
$str_start = strtotime($str_start);
$str_end = strtotime($str_end);
$nseconds = $str_end - $str_start;
$ndays = round($nseconds / 86400);
$nseconds = $nseconds % 86400;
$nhours = round($nseconds / 3600);
$nseconds = $nseconds % 3600;
$nminutes = round($nseconds / 60);
$nseconds = $nseconds % 60;
if ($ndays == 0)
if($nhours == 0)
if($nminutes == 0)
return array($nseconds);
else
return array($nminutes, $nseconds);
else
return array($nhours, $nminutes, $nseconds);
else
return array($ndays, $nhours, $nminutes, $nseconds);
}
date_diff("2007/03/16 12:30:50", "2007/03/16 14:00:00");
This is a function that compares two dates with each other and let's see how much there is left in seconds, minutes, hours, days.
I didn't know at all how to do the arrays but a friend gave me if else and return array stuff, the purpose is that first if for example the days and hours are 0 it only shows the minutes and seconds.
Can anyone tell me if I'm ussing the array's wrong or/and how i get the output from these?
Thanks, Jens.