Get Difference Between Two Times

0
546

The following function will help you get the difference from two dates in PHP. You need to specify the 2 dates when you call the function in PHP.

function dateDifffun($date1, $date2){
    	$datetime1 = new DateTime($date1);
  $datetime2 = new DateTime($date2);
  $interval = $datetime1->diff($datetime2);
  return $interval->format('%H:%I');
}

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here