Sunday, 4 October 2009

PHP convert minutes to hours

PHP convert minutes to hours

Just a little function i made;

function minutes_to_hours($inmin){
$lh = floor($inmin/60);
$lm = $inmin - ($lh*60);
if ($lh > 0) return $lh.'h '.$lm.'m';
return '0h '.$lm.'m';
}

So calling minutes_to_hours(125) = 2h 5m

No comments: