<?php /** * Converts a 'decimal time' in the format 1.5hours to DateInterval object * * @param Int $decimalTime * @return DateInterval */ function decTimeToInterval($decimalTime) { $hours = floor($decimalTime); $decimalTime -= $hours; $minutes = floor($decimalTime * 60); $decimalTime -= ($minutes/60); $seconds = floor($decimalTime * 3600); $interval = new \DateInterval("PT{$hours}H{$minutes}M{$seconds}S"); return $interval; } echo decTimeToInterval(512.168)->format("%H:%I:%S");
You have javascript disabled. You will not be able to edit any code.