Here's the code which calculates the number of days between two dates.
Code: Select all
function numberDays($date1, $date2) {
// make dates using mktime because PHP v < 5.3
$dateExplode1 = explode("-", $date1->format('m-d-Y'));
$dateExplode2 = explode("-", $date2->format('m-d-Y'));
// echo $date1->format('m-d-Y') . "<br />";
// echo $date2->format('m-d-Y') . "<br />";
$ts1 = mktime(0,0,0, $dateExplode1[0], $dateExplode1[1], $dateExplode1[2]);
$ts2 = mktime(0,0,0, $dateExplode2[0], $dateExplode2[1], $dateExplode2[2]);
$numSeconds = abs($ts1 - $ts2);
// echo "numSeconds = $numSeconds<br />";
$numDays = floor($numSeconds / 86400); // 86400 = 60 * 60 * 24
// echo "numDays = $numDays<br /><br />";
return $numDays;
}numDays = 71 (using PHP v5.2.x)
numDays = 72 (using PHP v5.3.5) and this is the correct one.
Any fixes for this other than the obvious of getting a new host.
Thanks