3v4l.org

run code in 300+ PHP versions simultaneously
<?php function xtemplate_formatter_secToTime($rawSeconds, $useSec = false, $convertHoursToDays = false) { $allSeconds = abs($rawSeconds); $days = floor($allSeconds / 86400); $hoursSeconds = $allSeconds - 86400 * $days; $hours = floor($hoursSeconds / 3600); $minutesSeconds = $hoursSeconds - 3600 * $hours; $minutes = floor($minutesSeconds / 60); if ($useSec) { $seconds = $minutesSeconds - 60 * $minutes; } if (!$convertHoursToDays) { $hours = $days * 24 + $hours; $days = 0; } if ($hours < 10) { $hours = "0" . $hours; } if ($minutes < 10) { $minutes = "0" . $minutes; } if ($useSec && $seconds < 10) { $seconds = "0" . $seconds; } $str = ''; if ($days > 0) { $str .= $days . 'd'; } $str = $str . $hours . ":" . $minutes; if ($useSec) { $str .= ":" . $seconds; } return $str; } echo xtemplate_formatter_secToTime(35353, true);

preferences:
85.34 ms | 402 KiB | 5 Q