Search code examples
phpdatetimephp-5.3

PHP `DateTime::days` returns trash?


PHP Class DateInterval has a property "days". According to the manual it returns "Total number of days the interval spans. If this is unknown, days will be FALSE."

In my case the code:

$d = new DateInterval('P1Y'); 
echo $d->days;

returns -99999

and a code like this

$a = DateTime::createFromFormat("d.m.Y", "01.01.2010");
$b = DateTime::createFromFormat("d.m.Y", "03.01.2010");

$d = $b->diff($a);
echo $d->days;

returns 6015

Did I misunderstand something?


Solution

  • DateInterval is buggy on windows platform. See bug #51183. The official answer seems to be "use VC9 builds instead for now".