|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-06-21 21:11 UTC] nikic@php.net
[2019-06-21 21:20 UTC] v-yitam at microsoft dot com
[2019-06-21 23:05 UTC] daverandom@php.net
-Status: Open
+Status: Not a bug
[2019-06-21 23:05 UTC] daverandom@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 05:00:01 2025 UTC |
Description: ------------ This seemingly happens with datetime objects only, not with simple user defined objects. Reproducible with PHP 7.4 Alpha 1 but not with PHP 7.3.6 Test script: --------------- <?php class foo { public $a; public $b; } $bar = new foo; $bar->a = 'A'; $bar->b = 'B'; var_dump($bar); $arr = (array) $bar; var_dump($arr); $date = date_create('2018-12-31 23:59:59.997'); date_default_timezone_set("America/Los_Angeles"); var_dump($date); $darr = (array) $date; var_dump($darr); ?> Expected result: ---------------- object(foo)#1 (2) { ["a"]=> string(1) "A" ["b"]=> string(1) "B" } array(2) { ["a"]=> string(1) "A" ["b"]=> string(1) "B" } object(DateTime)#2 (3) { ["date"]=> string(26) "2018-12-31 23:59:59.997000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } array(3) { ["date"]=> string(26) "2018-12-31 23:59:59.997000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } Actual result: -------------- object(foo)#1 (2) { ["a"]=> string(1) "A" ["b"]=> string(1) "B" } array(2) { ["a"]=> string(1) "A" ["b"]=> string(1) "B" } object(DateTime)#2 (3) { ["date"]=> string(26) "2018-12-31 23:59:59.997000" ["timezone_type"]=> int(3) ["timezone"]=> string(3) "UTC" } array(0) { }