PHP `DateTime::days` returns trash?

谁都会走 提交于 2019-12-01 16:49:45

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

I just run your examples and they should work. Specifically I got:

    $d = new DateInterval('P1Y');
    var_dump($d->days);
    // result: int 0


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

    $d = $b->diff($a);
    var_dump($d->days);
    // result: int 2

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

Can u please tell me your exact solution you need...

I have used the code below,

$interval = new DateInterval('P2Y4DT6H8M');

echo $interval->d;

it gives the o/p as 4

if i use like this,

$interval = new DateInterval('P2Y');

echo $interval->d;

it gives o/p as 0

So it will return the day u have given in Dateinterval() otherwise it will return zero..

U tell me ur exact requirement please.......... :)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!