Req #62911 [NEW]: Add DateTime::__toString()

From: Date: Thu, 23 Aug 2012 18:15:37 +0000
Subject: Req #62911 [NEW]: Add DateTime::__toString()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-172840@lists.php.net to get a copy of this message
From: bdurand-php at ssji dot net Operating system: PHP version: Irrelevant Package: Date/time related Bug Type: Feature/Change Request Bug description:Add DateTime::__toString() Description: ------------ Hello, I want to have a default behavior to convert an instance of the class DateTime into a string. I mean implement the method __toString() in the DateTime class. The default format should be ISO8601 IMHO, but we can add an attribut to define the default format to use for __toString() and format() method. Greetings. Test script: --------------- <?php $datetime = new DateTime(); echo $datetime; Expected result: ---------------- 2012-08-23T20:11:21+0200 Actual result: -------------- PHP Catchable fatal error: Object of class DateTime could not be converted to string in php shell code on line 1 -- Edit bug report at https://bugs.php.net/bug.php?id=62911&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=62911&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=62911&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=62911&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=62911&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62911&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=62911&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=62911&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=62911&r=needscript Try newer version: https://bugs.php.net/fix.php?id=62911&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=62911&r=support Expected behavior: https://bugs.php.net/fix.php?id=62911&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=62911&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=62911&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=62911&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=62911&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=62911&r=dst IIS Stability: https://bugs.php.net/fix.php?id=62911&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=62911&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=62911&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=62911&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=62911&r=mysqlcfg

« previous php.bugs (#172840) next »