The code is as follows
//function: Calculates the difference between two timestamp seconds//$begin _time start timestamp//$end _time end TimestampfunctionTimediff ($begin _time,$end _time){ if($begin _time<$end _time){ $starttime=$begin _time; $endtime=$end _time; }Else{ $starttime=$end _time; $endtime=$begin _time; } //Count Days $timediff=$endtime-$starttime; $days=intval($timediff/86400); //Count hours $remain=$timediff%86400; $hours=intval($remain/3600); //Count the number of minutes $remain=$remain%3600; $mins=intval($remain/60); //calculate the number of seconds $secs=$remain%60; $res=Array("Day" + =$days, "Hour" =$hours, "min" =$mins, "SEC" =$secs); return $res;}
Print_r (Timediff (strtotime(2016-09-12 12:00:00 '), Strtotime (' 2016-09-15 21:50:21 '));
Strtotime is converting time to timestamp format
Calculates a time difference between two timestamps