Two date get hour and minute using php

0

Today, we’ll discuss how to calculate date and time difference in PHP. The easiest way to calculate the time difference in PHP is using diff function(). You may also like Get total minute and second difference between two dates using php

Code

$current_date = date('Y-m-d H:i');
$datebase_date = date('2018-03-09 08:40');
$datetime1 = new DateTime($current_date);
$datetime2 = new DateTime($datebase_date);
$interval = $datetime1->diff($datetime2);
echo $interval->format('%h')." Hours ".$interval->format('%i')." Minutes";