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 78 views
1 answer 81 views
1 answer 105 views
1 answer 87 views
1 answer 101 views
1 answer 93 views
1 answer 169 views
...