Edit report at https://bugs.php.net/bug.php?id=49382&edit=1
ID: 49382 Comment by: weirdan at gmail dot com Reported by: klawd at kamundo dot de Summary: can't access DateTime->date Status: Assigned Type: Bug Package: Date/time related Operating System: Debian GNU/Linux 5.0 PHP Version: 5.3.0 Assigned To: derick Block user comment: N Private report: N New Comment: I'd say the bug is not that the property is not present before var_dump'ing object, but that the property is suddenly created. Unexpected side-effect. Previous Comments: ------------------------------------------------------------------------ [2013-07-09 11:29:41] hanskrentel at yahoo dot de I wonder how this qualifies as a bug as any object can have variable properties and accessing undefined ones give notices. Just sounds like standard PHP behavior here. ------------------------------------------------------------------------ [2012-12-29 17:56:02] info at metashock dot net I think it is interesting that the property can be accessed using reflection. Using the following example I can access the property: $dt = new DateTime(); $o = new ReflectionObject($dt); $p = $o->getProperty('date'); $date = $p->getValue($dt)); // returns the value of DateTime::$date ------------------------------------------------------------------------ [2010-08-04 22:36:58] weirdan at gmail dot com if this was not intended to work this way, why won't you just fix it so that no properties are created as a result of print_r / Reflection::export() / foreach() / property_exist / array cast? ------------------------------------------------------------------------ [2010-03-07 20:22:06] der...@php.net ->date being available is actually a side-effect of support for var_dump() here. I'll mark this as a feature request as it was not intended to work. ------------------------------------------------------------------------ [2009-08-27 07:52:37] klawd at kamundo dot de Description: ------------ Can not access property date of DateTime. Reproduce code: --------------- $dt=new DateTime('1742-05-23 00:00:00'); echo $dt->date; gets me Notice: Undefined property: DateTime::$date strangely though, this works: $dt=new DateTime('1742-05-23 00:00:00'); print_r($dt); echo $dt->date; DateTime Object ( [date] => 1742-05-23 00:00:00 [timezone_type] => 3 [timezone] => UTC ) 1742-05-23 00:00:00 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=49382&edit=1