$dec = 0.625;
Это просто. Для преобразования десятичных знаков часов, сделать умножение 24.
$hours = $dec * 24;
Теперь для преобразования десятичных знаков hours:mins
использования этого:
function convertTime($dec)
{
// start by converting to seconds
$seconds = ($dec * 3600);
// we're given hours, so let's get those the easy way
$hours = floor($dec);
// since we've "calculated" hours, let's remove them from the seconds variable
$seconds -= $hours * 3600;
// calculate minutes left
$minutes = floor($seconds/60);
// remove those from seconds as well
$seconds -= $minutes * 60;
// return the time formatted HH:MM:SS
return lz($hours).":".lz($minutes).":".lz($seconds);
}
// lz = leading zero
function lz($num)
{
return (strlen($num) < 2) ? "0{$num}" : $num;
}
echo convertTime($hours);
Источник:How to convert a decimal into time, eg. HH:MM:SS
Выходной : http://ideone.com/Q7lkwX
Как '0.625' равен' 15: 00'? –
О, я понял, 0,625 * 24 = 15 – manu
Не могли бы вы показать свой код, который не сработал? – simon