I have a function which calculate the difference between two timestamps,
public static function getDuration($from, $to) {
$duration = $to - $from;
return $duration;
}
but this is not working as required.
example, if i pass,
$difference = getDuration(strtotime('19-07-2012 23:00:00'), strtotime('20-07-2012 4:45:00'));
echo $difference/3600;
it returns 5.75 instead of 5.45, when converted to hours.
it returns ok – 5,75 is 5 3/4 hours = 5 hours 45 minutes
It returns in decimal – not hours/minutes
if you want hours/minutes you can use: