If your dates are in the user friendly format (Y-m-d etc.)
you can use mktime function in order to change current format
to UNIX format. Newest value means number of seconds since 1.1.1970
and when you have two of these values you can easy subtract one from
the other and then convert second to H:m:s format.
Example:
Code:
function convert_this_date_to_unix_date($date)
{
/*
mktime func accept following params
int hour, int minute, int second, int month, int day, int year
and we have to explode $date value for the preparing for
mktime func's usage
*/
$date_sections=explode(" ", $date);
$date_section=explode("-", $date_sections[0]);
$time_section=explode(":", $date_sections[1]);
$am_pm=($date_sections[2]=="PM")?12:0;
return mktime ($time_section[0]+$am_pm, $time_section[1], $time_section[2],
$date_section[1], $date_section[2], $date_section[0]);
}
$date1="2003-05-05 10:12:23 PM"
$date2="2003-05-06 11:12:23 PM"
//mktime
$date1_unix=convert_this_date_to_unix_date($date1);
$date2_unix=convert_this_date_to_unix_date($date2);
$diff=$date2_unix-$date1_unix;
$diff_in_hourminutesecond_format=date('H:i:s',$diff);
HTH.
Regs,
NotNowJohn
...but the Soon is eclipsed by the Moon