I have an array of times as below:
Array
(
[0] => 00:00:04
[1] => 00:00:05
[2] => 00:00:02
[3] => 00:00:09
[4] => 00:00:03
[]...
)
And I am trying to work out the average time using the code below:
foreach($times as $t) {
$unixtime += strtotime($t);
}
$unixtime = $unixtime / count($times);
echo "Unix Time: " . $unixtime . "<br />";
echo "Formatted: " . date("h:i:s",$unixtime) . "<p/>";
But the output I am getting is:
Unix Time: 1345669204.37
Formatted: 12:00:04
Can anyone please tell me what I am doing wrong?
If you change the date format string from
h:i:stoH:i:sit should start working.The
hformat is used for 12hr clock and starts at12for midnight; the 24hr clock starts at00.