Possible Duplicate:
Getting the difference between two time/dates using php?
I have two dates variable let $arrival_time="7.30 AM"; $departure_time="8.30 PM";
Then how can I calculate the time difference between these two variables in php ?
Possible Duplicate:
Getting the difference between two time/dates using php?
I have two dates variable let $arrival_time="7.30 AM"; $departure_time="8.30 PM";
Then how can I calculate the time difference between these two variables in php ?
<?php
$arrival_time="7.30 AM";
$departure_time="8.30 PM";
$d1= strtotime($arrival_time);
$d2= strtotime($departure_time);
$diff=$d2-$d1;
//Print the difference in hours : minutes
echo date("H:i",$diff);
?>
<?php
$am = "7:30AM";
$pm = "8:30PM";
$minutes_diff = round(abs(strtotime($pm) - strtotime($am)) / 60);