title: calculate time interval using record saved after each 5 min
body: <p>i have records in data base like </p>
  
  <pre><code>id      Time
  1       25-02-2015 18:20
  2       25-02-2015 18:25
  3       25-02-2015 18:30
  4       25-02-2015 18:45
  5       25-02-2015 18:50
  6       25-02-2015 18:55
  </code></pre>
  
  <p>I want to add time interval form 1 to 3  and 4 to 6,
  and display only two records instead all six.</p>
  
  <p>I tried but confuse with this easy(may be) task</p>
  
  <pre><code>foreach($list as $i =&gt; $listInfo){
          if(isset($list[$i+1]['dd_data']))
          {
              $nexttime = $list[$i+1]['dd_data'] ; 
  
              $to_time = strtotime($nexttime);
              $from_time = strtotime($listInfo['dd_data']);
              $diff =  round(abs($to_time - $from_time) / 60,2);
              if($diff&lt;=5)
              {
                  $diffsum +=$diff;   
              }
          }else{
                  $diffsum = '0'; 
              }
  
  
          if($diffsum&gt;=5 &amp;&amp; $diff&gt;=5)
          {
          ?&gt;
          &lt;tr class="&lt;?=$class?&gt;"&gt;
              &lt;td  class="&lt;?=$leftBotClass?&gt;"&gt;&lt;?=$c++?&gt; &lt;?=$diff?&gt;&lt;/td&gt;               
              &lt;td class="td_br_right left"&gt;&lt;?php echo $listInfo['dd_data']; ?&gt; Till next  &lt;?php echo $diffsum; ?&gt; min &lt;/td&gt; 
          &lt;/tr&gt;
          &lt;?php
          }
      }
  </code></pre>
  
  <p>Thanks  </p>