How to find the difference between these two times.
I have two times
$start_time = '09:30 PM';
$end_time = '10:45 PM';
I want the output
1h 15m.
How to do with php??
Hey friend this will work -
$datetime1 = new DateTime('09:30 PM');
$datetime2 = new DateTime('10:45 PM');
$interval = $datetime1->diff($datetime2);
echo $interval->format('%hh %im');
Output -
1h 15m
Here %h
indicates hours and %i
as minutes. (and h and m after %h
and %i
respectively are just strings for display)
For more details of format()
hour or in minutes check here