ID: 49778
User updated by: jenwelsh at yahoo dot com
Reported By: jenwelsh at yahoo dot com
Status: Open
Bug Type: Date/time related
Operating System: Solaris 10
PHP Version: 5.3.0
New Comment:
DateInterval::format with %a format does work if the DateInterval is
the result of getting the difference between two DateTime objects:
$d1=date_create('2009-11-02');
$d2=date_create('2009-11-09');
$i=$d2->diff($d1);
echo $i->format("%d");//7
echo $i->format("%a");//7
Previous Comments:
------------------------------------------------------------------------
[2009-10-05 14:32:08] jenwelsh at yahoo dot com
Description:
------------
DateInterval cannot output the total days. It always outputs 0.
Reproduce code:
---------------
---
>From manual page: dateinterval.format#Return Values
---
$i=new DateInterval('P7D');
print_r($i);
echo $i->format("%d");
echo $i->format("%a");
Expected result:
----------------
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 7
[h] => 0
[i] => 0
[s] => 0
[invert] => 0
[days] => 0
)
7
7
Actual result:
--------------
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 7
[h] => 0
[i] => 0
[s] => 0
[invert] => 0
[days] => 0
)
7
0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49778&edit=1