convert minutes to hours in php code example

Example 1: seconds to minutes php

echo gmdate("H:i:s", 685);

Example 2: seconds to days hours minutes seconds php

function seconds2human($ss) {
$s = $ss%60;
$m = floor(($ss%3600)/60);
$h = floor(($ss%86400)/3600);
$d = floor(($ss%2592000)/86400);
$M = floor($ss/2592000);

return "$M months, $d days, $h hours, $m minutes, $s seconds";
}

Example 3: php convert minutes to hours and minutes

$hours = floor($final_time_saving / 60);
$minutes = $final_time_saving % 60;

Example 4: change minutes in to hours carbon

You can use:
----------------
$minutes = 1510;
$hours = intdiv($minutes, 60).':'. ($minutes % 60);
!!! This only works with php >= v7.xx

Previous answer:
-------------------
$minutes = 1510;
$hours = floor($minutes / 60).':'.($minutes - floor($minutes / 60) * 60);

Tags:

Php Example