PHP `DateTime :: days` returns cart?

The PHP class DateInterval has the "days" property. According to the manual, it returns Msgstr "The total number of days the interval passes. If this is not known, the days will be FALSE."

In my case, the code is:

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

returns -99999

and such a code

 $a = DateTime::createFromFormat("dmY", "01.01.2010"); $b = DateTime::createFromFormat("dmY", "03.01.2010"); $d = $b->diff($a); echo $d->days; 

returns 6015

I didn’t understand something?

+7
source share
3 answers

DateInterval does not work on the Windows platform. See bug # 51183 . The official answer seems to be now used to use VC9 instead.

+7
source

I am just running your examples and they should work. In particular, I received:

  $d = new DateInterval('P1Y'); var_dump($d->days); // result: int 0 $a = DateTime::createFromFormat("dmY", "01.01.2010"); $b = DateTime::createFromFormat("dmY", "03.01.2010"); $d = $b->diff($a); var_dump($d->days); // result: int 2 

I am running XAMPP for Linux 1.7.3a with PHP 5.3.1 on Linux Mint 10.

+2
source

Could you tell me your exact solution that you need ...

I used the code below

 $interval = new DateInterval('P2Y4DT6H8M'); 

echo $ interval-> d;

he gives o / p as 4

if i use this

 $interval = new DateInterval('P2Y'); echo $interval->d; 

it gives o / p as 0

That way it will return the day specified in Dateinterval (), otherwise it will return zero ..

U please tell me the exact requirement, please .......... :)

0
source

All Articles