I have two dates and i want to get the amount of time between them.
I try this:
$created_dt="2014-01-30 09:27:02";
$done_dt="2014-01-30 16:29:38";
$created_dt=strtotime($created_dt); //1391066822
$done_dt=strtotime($done_dt); //1391092178
$runing_time= $created_dt-$done_dt; //25356
$runing_time= date('H:i',$runing_time);
echo $runing_time; // "09:02" <----------???????
why is $runing_time = 09:02 ???
what is a good way around this?
thanks
Part 2
how can i sum a few $intervals together? and after that get their average?
I try:
$average_time;
foreach($tasks as $task)
{
$date1 = new DateTime($task['start']);
$date2 = new DateTime($task['end']);
$interval = $date1->diff($date2);
$runing_time=$interval->format("%h hours, %i minutes, %s seconds");
$average_time+=$interval ;
}
$final_average_time=average_time/4;
obviously my code didnt work because $interval is a an object.