I'm iterating through an array of objects and each object has a time attribution. As I iterate through the array I want to calculate the total time. Not sure how to add minutes in the time. Please refer to this screenshot Only hours are getting added. Code to add the time is written below
$total_human_readable_time += humanReadableTime($total_workhours);
Function humanReadableTime is defined below
function humanReadableTime($time) {
$time = abs($time);
$hours = floor($time);
$minutes = ceil(($time - floor($time)) * 60);
if ($minutes < 10) {
$minutes = "0$minutes";
}
return $hours . ":" . $minutes;
}