-3

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 ?

Community
  • 1
  • 1
Kabul Patel
  • 39
  • 2
  • 3

2 Answers2

1
<?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);
?>
MilMike
  • 12,571
  • 15
  • 65
  • 82
0
<?php
$am = "7:30AM";
$pm = "8:30PM";
$minutes_diff = round(abs(strtotime($pm) - strtotime($am)) / 60);
Rawkode
  • 21,990
  • 5
  • 38
  • 45