Convert minutes (also negative) like 200 or -300, in the +/-mm:ss notation (+05:00 or -06:00). Useful when working with timezone.
function convertToHoursMins($time) {
$sign = '+';
if ($time < 0)
$sign = '-';
$time = abs($time);
$hours = floor($time / 60);
$minutes = ($time % 60);
return $sign . sprintf('%02d:%02d', $hours, $minutes);
}
echo convertToHoursMins(-100);