Bug #76057 [NEW]: For DateTime the properties 'timezone' and 'timezone_type' are not set on init

From: Date: Mon, 05 Mar 2018 21:04:46 +0000
Subject: Bug #76057 [NEW]: For DateTime the properties 'timezone' and 'timezone_type' are not set on init
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214213@lists.php.net to get a copy of this message
From: projectcleverweb at gmail dot com Operating system: Linux PHP version: 7.2.3 Package: Date/time related Bug Type: Bug Bug description:For DateTime the properties 'timezone' and 'timezone_type' are not set on init Description: ------------ In short, these to properties are not set when the class is instantiated, but do become set when the class is serialized OR when the property list is requested (such as via get_object_vars()). You can see the conditions when timezone_type will be set on this page by just searching in the browser for "timezone_type" https://github.com/php/php-src/blob/ef255c9f0f2c2ad1ea224ed215edb00f5bc205bd/ext/date/php_date.c#L2269 This issue is occurring on PHP 5.6 and later (shown in the test script URL) Test script: --------------- https://3v4l.org/ZhQX9 --- OR --- $test = new DateTime('2018-03-05 00:00:00', new DateTimeZone('UTC')); var_dump($test->timezone); // Notice: Undefined property: DateTime::$timezone get_object_vars($test); var_dump($test->timezone); // string(3) "UTC" Expected result: ---------------- string(3) "UTC" string(3) "UTC" Actual result: -------------- Notice: Undefined property: DateTime::$timezone in /in/BQD1t on line 5 NULL string(3) "UTC" -- Edit bug report at https://bugs.php.net/bug.php?id=76057&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76057&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76057&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76057&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76057&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76057&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76057&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76057&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76057&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76057&r=support Expected behavior: https://bugs.php.net/fix.php?id=76057&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76057&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76057&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76057&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76057&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76057&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76057&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76057&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76057&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76057&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76057&r=mysqlcfg

« previous php.bugs (#214213) next »