I am using 2 timestamp in my table which is starttime datatype- timestamp and as current timestamp. endtime datatype-timestamp and default as 0000-00-00 00:00:00
ho
I have created one function which helps you to get Hours, Minutes and Days from the two Unix timestamps by just passing type as 3rd parameter.
public function diffBtwTimesAsPerType($start, $end, $returnType=1) {
$seconds_diff = $start - $end;
if($returnType == 1){
return $seconds_diff/60;//minutes
}else if($returnType == 2){
return $seconds_diff/3600;//hours
}else{
return $seconds_diff/3600/24; //days
}
}
echo "
Minutes = ".diffBtwTimesAsPerType(1593714600, 1593541800, 1);//minutes
echo "
Hours = ".diffBtwTimesAsPerType(1593714600, 1593541800, 2);//hours
echo "
Days = ".diffBtwTimesAsPerType(1593714600, 1593541800, 3);//days