DEV Community

Vishnu Choudhary
Vishnu Choudhary

Posted on

php difference between am pm time in hours and minutes [duplicate]

$datetime1 = new DateTime('09:30 PM');
$datetime2 = new DateTime('10:45 PM');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%hh %im');

Output -

1h 15m

Top comments (0)