Doc #52069 [Opn->Csd]: DateTime::sub( ), DateTime::add( ), etc...

From: Date: Wed, 20 Oct 2010 02:16:56 +0000
Subject: Doc #52069 [Opn->Csd]: DateTime::sub( ), DateTime::add( ), etc...
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5260@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52069&edit=1 ID: 52069 Updated by: kalle@php.net Reported by: wdolek at gmail dot com Summary: DateTime::sub( ), DateTime::add( ), etc... -Status: Open +Status: Closed Type: Documentation Problem Package: Documentation problem Operating System: Fedora 12, 2.6.32.11-99 PHP Version: 5.3.2 -Assigned To: +Assigned To: kalle Block user comment: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2010-10-20 04:16:35] kalle@php.net Automatic comment from SVN on behalf of kalle Revision: http://svn.php.net/viewvc/?view=revision&revision=304524 Log: Fixed bug #52069 (DateTime::sub( ), DateTime::add( ), etc...) ------------------------------------------------------------------------ [2010-06-13 15:43:27] derick@php.net The reason why it returns the instance, is so that you can do for example: $d->add("+2 days")->modify("next weekday")->sub("1 month"); ------------------------------------------------------------------------ [2010-06-12 22:05:04] wdolek at gmail dot com 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 this bug report at http://bugs.php.net/bug.php?id=52069&edit=1

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