3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function average_time($total, $count, $rounding = 0) { $total = explode(":", strval($total)); if (count($total) !== 3) return false; $sum = $total[0]*60*60 + $total[1]*60 + $total[2]; $average = $sum/(float)$count; $hours = floor($average/3600); $minutes = floor(fmod($average,3600)/60); $seconds = number_format(fmod(fmod($average,3600),60),(int)$rounding); return $hours.":".$minutes.":".$seconds; } echo average_time("190:24:00", 15);
based on A4iMh
Output for 4.3.0 - 5.6.38, hhvm-3.10.1 - 3.22.0, 7.0.0 - 7.3.0rc3
12:41:36