title: php average of timestamp
body: <p>I want to calculate average of time-in for a user for particular duration , i have timestamp values for each time-in .
  To calculate average i want to add all timestamps and divide by no of days .
  But sum of all timestamps gives wrong input so i want convert timestamps to seconds so i can add them and calculate average .
  I am using following code .</p>
  
  <pre><code>$timeInTotalSec = 0;
  $timeInTotalSec += intval(date("H",$punchintime)) * 60 * 60;
  $timeInTotalSec += intval(date("i",$punchintime)) * 60;
  $timeInTotalSec += intval(date("s",$punchintime));`
  </code></pre>
  
  <p>but</p>
  
  <pre><code>date("H",$punchintime)
  </code></pre>
  
  <p>gives me proper value but </p>
  
  <pre><code>intval(date("H",$punchintime))
  </code></pre>
  
  <p>giving me <strong>0</strong></p>
  
  <p>Thanks in advance .</p>