Min to hours convertion problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • apking
    New Member
    • Feb 2007
    • 32

    Min to hours convertion problem

    Hi Here is my Code. Iam trying to convert min to hours. buts its coming 160.5 instead of 160.3.help me in that pls..


    Code:
    while($res_proj_hrs = mysql_fetch_object($qry_proj_hrs))
    								{
    									$hr   = $res_proj_hrs->hrs;
    									$min  = $res_proj_hrs->mins;
    									if($hr || $min){
    										$getHour =getCorrectTime($hr,$min);
    										$totmin = $hr * 60 + $min;
    										$tothour += $totmin;
    									//$tothour = $tothour + $getHour;
    									}
    									else
    										$getHour = "0.00";
    
    //Print line
    <td  align='center'><?php echo $tothour / 60 ?></td>
    regards
    apking
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    If you're talking about 9630 minutes then that is 160.5 hours. Or 160 and a half hours. That's correct. 160.3 hours would be wrong.

    Comment

    • Sudaraka
      New Member
      • Jan 2011
      • 55

      #3
      Or if you are trying to display it like a digital clock, in hh:mm format. Try something like this.
      Code:
      $tothour=9630;
      
      $h=intval($tothour/60);
      $m=$tothour%60;
      
      echo $h.':'.$m;

      Comment

      Working...