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 .
$timeInTotalSec = 0;
$timeInTotalSec += intval(date("H",$punchintime)) * 60 * 60;
$timeInTotalSec += intval(date("i",$punchintime)) * 60;
$timeInTotalSec += intval(date("s",$punchintime));`
but
date("H",$punchintime)
gives me proper value but
intval(date("H",$punchintime))
giving me 0
Thanks in advance .