Jump to content

[SOLVED] How can I calculate hours from minutes


Space Cowboy

Recommended Posts

Hi there,

 

Im creating a job sheet system, where people enter how many minutes they have spent on a job.

The minutes are totaled up and im left with a total like: 465 (minutes).

I need something that will break that down into hours. (465 minutes is equal to 7 hours and 45 mins).

If I try this calculation: 465 / 60 it equals 7.75. It needs to be 7.45 and I cant find the answer anywhere 

 

Any help would be massively appreciated

 

http://www.php.net/manual/en/language.operators.arithmetic.php

 

$totalMinutes = 465;
$hours = (int)($totalMinutes / 60);
$minutes = $totalMinutes % 60;

echo $hours.":".$minutes;

 

not tested, but should work

 

[edit] some ordering in variable names

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.