Doc #52069 [NEW]: DateTime::sub( ), DateTime::add( ), etc...

From: Date: Sat, 12 Jun 2010 20:05:05 +0000
Subject: Doc #52069 [NEW]: DateTime::sub( ), DateTime::add( ), etc...
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-4535@lists.php.net to get a copy of this message
From: Operating system: Fedora 12, 2.6.32.11-99 PHP version: 5.3.2 Package: Documentation problem Bug Type: Documentation Problem Bug description:DateTime::sub( ), DateTime::add( ), etc... Description: ------------ http://www.php.net/manual/en/datetime.sub.php documentation says: DateTime::sub — Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object Return Values Returns the modified DateTime object or FALSE on failure. this is fine, but it is not clear that "sub" or "add" modify value on called instance, and then - really dont know why - returns that instance (again). Test script: --------------- $d1 = new DateTime(); $d2 = $d1->sub(new DateInterval('P1W')); var_dump($d1); var_dump($d2); var_dump($d1 === $d2); Expected result: ---------------- object(DateTime)[1] public 'date' => string '2010-06-12 22:01:55' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'Europe/Wdoltown' (length=13) object(DateTime)[2] public 'date' => string '2010-06-05 22:01:55' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'Europe/Wdoltown' (length=13) boolean false Actual result: -------------- object(DateTime)[1] public 'date' => string '2010-06-05 22:01:55' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'Europe/Wdoltown' (length=13) object(DateTime)[1] public 'date' => string '2010-06-05 22:01:55' (length=19) public 'timezone_type' => int 3 public 'timezone' => string 'Europe/Wdoltown' (length=13) boolean true -- Edit bug report at http://bugs.php.net/bug.php?id=52069&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52069&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52069&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52069&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52069&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52069&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52069&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52069&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52069&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52069&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52069&r=support Expected behavior: http://bugs.php.net/fix.php?id=52069&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52069&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52069&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52069&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52069&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52069&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52069&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52069&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52069&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52069&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52069&r=mysqlcfg

« previous php.doc.bugs (#4535) next »