Possible Duplicate:
get difference in time in HH:MM format php
my time format is d/m/Y – h:ia
example output is 21/10/2012 – 03:49pm
I’m using this code to calculate the difference between $from and $to
$to = strtotime("21/10/2012 - 10:30pm");
$from = strtotime("22/10/2012 - 8:30am");
$stat = date("H\h:i\m", abs($to - $from));
but I’m alwys getting an incorrect value
for the example above I got an output of 16h:00m but it should be 10h:00m
is there a much more efficient and effective way to do this?
This format is incorrect and unrecognized by strtotime (see the third note) I suspect that your timezone is GMT-8 and you will always get 16h from dates in this format.
You have to convert manually this date to format recognized by php in order to do some calculations