From: moses dot liao at techlinkz dot net
Operating system: Linux
PHP version: 5.3.21
Package: Date/time related
Bug Type: Bug
Bug description:PHP DateTime Add and sub
Description:
------------
Using the current datetime, adding and subtracting one month does not
result in an actual one month addition and subtraction
Test script:
---------------
<td valign="top">
<?php
$previousMonth = new DateTime ('2013-03-31');
$previousMonth->sub (new DateInterval ('P1M'));
echo $previousMonth->format ('Y-m-d');
?>
</td>
<td valign="top">
<?php
$nextMonth = new DateTime ('2013-03-31');
$nextMonth->add (new DateInterval ('P1M'));
echo $nextMonth->format ('Y-m-d');
?>
</td>
Expected result:
----------------
previous month to show 2013-02-*, next month to show 2013-04-*
Actual result:
--------------
<td>2013-03-03</td><td>2013-05-01</td>
--
Edit bug report at https://bugs.php.net/bug.php?id=64052&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=64052&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=64052&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=64052&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64052&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64052&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64052&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64052&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64052&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64052&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64052&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=64052&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=64052&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64052&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64052&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64052&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64052&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64052&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64052&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64052&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64052&r=mysqlcfg