PHP `DateTime::days` returns trash?

后端 未结 3 1246
谎友^
谎友^ 2021-01-18 04:09

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 F

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-18 04:56

    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.

提交回复
热议问题