Home >> Snippet List >> Snippet

Name
Convert Minutes to Hours
Description
Another "Minutes to Hours" conversion script
PHP Snippet
<? php
 
FUNCTION m2h($mins) { 
            IF ($mins < 0) { 
                $min = ABS($mins); 
            } ELSE { 
                $min = $mins; 
            } 
            $H = FLOOR($min / 60); 
            $M = ($min - ($H * 60)) / 100; 
            $hours = $H   $M; 
            IF ($mins < 0) { 
                $hours = $hours * (-1); 
            } 
            $expl = EXPLODE(".", $hours); 
            $H = $expl[0]; 
            IF (EMPTY($expl[1])) { 
                $expl[1] = 00; 
            } 
            $M = $expl[1]; 
            IF (STRLEN($M) < 2) { 
                $M = $M . 0; 
            } 
            $hours = $H . "." . $M; 
            RETURN $hours; 
    } 
?>