I have an array,each element have a start_date and end_date.
I want to sum all the time periods between the two dates and divide them by 3 to get the average time period.
The Array
Array
(
[0] => Array
(
[start_date] => "2014-01-30 09:27:02"
[end_date] => "2014-01-30 16:29:38"
)
[1] => Array
(
[start_date] => "2014-01-28 09:27:02"
[end_date] => "2014-01-30 16:29:38"
)
[2] => Array
(
[start_date] => "2014-01-30 09:05:02"
[end_date] => "2014-01-30 12:12:38"
)
)
I need some thing like this:
$total=0;
foreach($array as $ar)
{
$created_dt=strtotime($ar[$start_date]);
$done_dt=strtotime($ar[$end_date]);
$runing_time= $created_dt - $done_dt - 2*3600;
$runing_time= date('H:i',$runing_time);
$total+=$runing_time;
}
$runing_time=$total/3;
what is a good way to do this?
thanks :)