Edit report at https://bugs.php.net/bug.php?id=54685&edit=1

 ID:                 54685
 Comment by:         bandy dot chris at gmail dot com
 Reported by:        ddynamic dot rahul at gmail dot com
 Summary:            Unexpected output for DATETIME:diff()
 Status:             Open
 Type:               Bug
 Package:            *General Issues
 Operating System:   Windows NT ABC-223D173EDE7 5.1 b
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

Related to bug 51184.


Previous Comments:
------------------------------------------------------------------------
[2011-07-10 04:03:21] denis dot beurive at gmail dot com

I confirm the bug on windows 7 :

$date1 = new DateTime("2011-07-03 00:00:00", new DateTimeZone('Europe/Paris'));
$date2 = new DateTime("2011-07-01 00:00:00", new DateTimeZone('Europe/Paris'));
$diff  = $date1->diff($date2);
echo 'diff(' . $date1->format('Y-m-d') . ',' . $date2->format('Y-m-d') . ' ) = 
' . $diff->format('%a') . '<br>';

Result : 

diff(2011-07-03,2011-07-01 ) = 6015

Regards,

Denis

------------------------------------------------------------------------
[2011-05-07 13:05:17] ddynamic dot rahul at gmail dot com

Description:
------------
---
I've followed all the reported bugs & forums. However, still not got any 
solution for this. Please help me to fix this bug. 
---
<?php
$datetime1 = new DateTime('2011-05-01');
$datetime2 = new DateTime('2011-05-07');
$interval = $datetime1->diff($datetime2); print_r($interval);
echo $interval->format('%R%a days');
?>

O/P: DateInterval Object ( [y] => 0 [m] => 0 [d] => 6 [h] => 0 [i] => 0 [s] => 
0 [invert] => 0 [days] => 6015 ) +6015 days

The o/p always gives the same unexpected result for any dates. i.e, +6015

Test script:
---------------
<?php
$datetime1 = new DateTime('2011-05-01');
$datetime2 = new DateTime('2011-05-07');
$interval = $datetime1->diff($datetime2); print_r($interval);
echo $interval->format('%R%a days');
?>

Expected result:
----------------
O/P: DateInterval Object ( [y] => 0 [m] => 0 [d] => 6 [h] => 0 [i] => 0 [s] => 
0 [invert] => 0 [days] => 6015 ) +6015 days

Actual result:
--------------
6 days


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=54685&edit=1

Reply via email to