Skip to content

Instantly share code, notes, and snippets.

@dokuzsekiz
Created February 24, 2015 08:27
Show Gist options
  • Save dokuzsekiz/4c7e902c51a60cece31b to your computer and use it in GitHub Desktop.
Save dokuzsekiz/4c7e902c51a60cece31b to your computer and use it in GitHub Desktop.
http://www.calculatorsoup.com/calculators/time/decimal-to-time-calculator.php
function decimalDayToTime($dec) {
$hours = $dec*24/1;
$stringArray = explode('.',$hours);
$hour = $stringArray[0];
$min = '0.'.$stringArray[1];
$minutes= $min * 60 /1;
$stringArray = explode('.',$minutes);
$minute = $stringArray[0];
$secondString = '0.'.$stringArray[1];
$second = round($secondString * 60 / 1);
if ($second = 60) {
$minute++;
$second = 0;
}
return $hour.':'.$minute.':'.$second;
}
echo decimalDayToTime(0.372222222222);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment