Convert Minutes To Hours

Description: Another “Minutes to Hours” conversion script.

<? 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;
    }
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.