From: Operating system: linux 32/64-bit, os-x PHP version: 5.3.3 Package: Date/time related Bug Type: Bug Bug description:DateTime::createFromFormat doesn't return a valid DateTime Object?
Description: ------------ When creating a new DateTime object via DateTime::createFromFormat() the date / timezone_type and timezone methods return: PHP Notice: Undefined property: ...etc. If you var_dump() the object however and then call these methods they suddenly work / return what is expected. See test script for example. Test script: --------------- <?php /* PHP 5.3.2 / 5.3.3 (cli) */ date_default_timezone_set('America/New_York'); $x = '2010-07-21 20:49:07'; // $tz = new DateTimeZone('America/New_York'); // broken even with out this. // $y = DateTime::createFromFormat('Y-m-d H:i:s', $x, $tz); // doesn't make a difference. $y = DateTime::createFromFormat('Y-m-d H:i:s', $x); echo $y->date; // PHP Notice: Undefined property: DateTime::$date var_dump($y); // Something magical happens. echo $y->date; // Suddenly this works. ?> Expected result: ---------------- Would expect to see the proper output of calling $y->date on line #15 and not need to call var_dump($y) to get it to work? Actual result: -------------- # php tmp.php PHP Notice: Undefined property: DateTime::$date in /path/to/tmp.php on line 15 PHP Stack trace: PHP 1. {main}() /path/to/tmp.php:0 object(DateTime)#1 (3) { ["date"]=> string(19) "2010-07-21 20:49:07" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "America/New_York" } 2010-07-21 20:49:07 # -- Edit bug report at http://bugs.php.net/bug.php?id=52535&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52535&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52535&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52535&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52535&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52535&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52535&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52535&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52535&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52535&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52535&r=support Expected behavior: http://bugs.php.net/fix.php?id=52535&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52535&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52535&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52535&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52535&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52535&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52535&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52535&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52535&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52535&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52535&r=mysqlcfg