Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 742
30thh Avatar asked Feb 08 '11 13:02

30thh


1 Answers

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

like image 167
meze Avatar answered Oct 15 '22 01:10

meze