the following code :
$start = new DateTime('2010-06-06');
$end = new DateTime('2011-02-04');
echo $start->diff($end)->days;
$start = new DateTime('2005-01-01');
echo $start->diff($end)->days;
will always return 6015 on windows platforms no matter on the date values. it is a bug regarding php 5.3.x on windows platforms #51184 and #49778. the solution to this is
to use the following code :
function dateDiff($dt1, $dt2, $timeZone = 'GMT') {
$tZone = new DateTimeZone($timeZone);
$dt1 = new DateTime($dt1, $tZone);
$dt2 = new DateTime($dt2, $tZone);
$ts1 = $dt1->format('Y-m-d');
$ts2 = $dt2->format('Y-m-d');
$diff = abs(strtotime($ts1)-strtotime($ts2));
$diff/= 3600*24;
return $diff;
}
echo dateDiff(’2010-10-10′, ’2010-10-12′);
hope it helps