How to convert hh:mm:ss to minutes in PHP

1 Answer

0 votes
function hhmmsstominutes($hhmmss) {
    $time = explode(':', $hhmmss);
    
    return ($time[0] * 60) + ($time[1]) + ($time[2] / 60); 
}
 
echo hhmmsstominutes("2:30:00"); 
echo "\n";
echo hhmmsstominutes("2:35:30"); 
echo "\n";
echo hhmmsstominutes("5:00:45"); 



/*
run:

150
155.5
300.75

*/

 



answered Apr 16, 2025 by avibootz

Related questions

1 answer 68 views
1 answer 76 views
1 answer 96 views
1 answer 83 views
1 answer 95 views
1 answer 85 views
1 answer 159 views
...