title: how to get time period between two dates
body: <p>I have two dates and i want to get the amount of time between them.<br>
  I try this:    </p>
  
  <pre><code>$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" &lt;----------??????? 
  </code></pre>
  
  <p>why is $runing_time = 09:02 ???    </p>
  
  <p>what is a good way around this?<br>
  thanks</p>
  
  <p>Part 2<br>
  how can i sum a few $intervals together? and after that get their average?<br>
  I try:       </p>
  
  <pre><code>   $average_time;
     foreach($tasks as $task)
     {
  
     $date1 = new DateTime($task['start']);
     $date2 = new DateTime($task['end']);
     $interval = $date1-&gt;diff($date2);
     $runing_time=$interval-&gt;format("%h hours, %i minutes, %s seconds");
     $average_time+=$interval ;
     }
     $final_average_time=average_time/4;
  </code></pre>
  
  <p>obviously my code didnt work because $interval is a an object. </p>