Hi.
I've used this function to calculate the number of days between to dates for a while, but when I tried to use it on some dates it suddenly gave me a result I can't quite understand. I try to calculate the number of days between 2007-10-31 and 2007-10-28 with this function:
function get_numdaysnew($from, $to){
$fromcmp = explode("-", $from);
$tocmp = explode("-", $to);
$fromcmpmk = mktime(0,0,0,$fromcmp[1],$fromcmp[2],$fromcmp[0]);
$tocmpmk = mktime(0,0,0,$tocmp[1],$tocmp[2],$tocmp[0]);
$diff = (($tocmpmk - $fromcmpmk) / 86400);
return $diff;
} //end function get_numdaysnew
$date_1 = '2007-10-28';
$date_2 = '2007-10-31';
$numday = get_numdaysnew($date_1, $date_2);
The function returns the result 3.04166666667. I can't understand this since I've set the hour/minute/second to 0 in my use of mktime-function.
Anybody to explain or to help me with a better function please?
Help would be much appreciated.