- round: documentation ( source)
- sscanf: documentation ( source)
- printf: documentation ( source)
<?php
$decimalTimes = [
6,
7.2,
8.78,
];
foreach ($decimalTimes as $decimalTime) {
sscanf($decimalTime, '%d%f', $hours, $minutes);
printf('%dh%02dm', $hours, round($minutes * 60));
echo "\n";
}