ID: 45696 Updated by: [EMAIL PROTECTED] Reported By: mathieuk at gmail dot com -Status: Open +Status: Assigned -Bug Type: Feature/Change Request +Bug Type: Date/time related Operating System: Mac OSX 10.5.3 PHP Version: 5.3CVS-2008-08-03 (CVS) -Assigned To: +Assigned To: derick New Comment:
It works for ->modify() already, and most of the other modification methods. Apparently I forgot to add it for ->add() and ->sub() though, so classifying this as a bug instead. php -r 'echo date_create("")->modify("+3 weeks")->format("c\n");' 2008-08-24T10:35:58+02:00 Previous Comments: ------------------------------------------------------------------------ [2008-08-03 08:25:14] mathieuk at gmail dot com Description: ------------ Feature request. Might be nice if the new DateTime::add(), DateTime::sub() and already existing DateTime::modify() methods would allow method chaining. Reproduce code: --------------- $datetime = new DateTime(); $interval = DateInterval::createFromDateString('2 weeks'); echo $datetime->add($interval)->format('d-m-Y H:i'); Expected result: ---------------- An echo'ed string showing the date of 2 weeks from 'now'. Actual result: -------------- Fatal error: Call to a member function format() on a non-object in /Users/mathieu/Source/tests/datetime/Modify.php on line 4 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45696&edit=1