|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-12-04 12:51 UTC] cmb@php.net
-Status: Open
+Status: Duplicate
-Assigned To:
+Assigned To: cmb
[2020-12-04 12:51 UTC] cmb@php.net
[2020-12-04 14:58 UTC] kontakt at nico-bayati dot de
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 10:00:02 2025 UTC |
Description: ------------ Maybe it is not a mistake, but I would like a consistent handling here. If 5-digit years are not desired, they should not be entered, otherwise it would be desirable that I can unserialize serialized objects, which contain 5-digit years Tested with php 7.2, 7.3 and 7.4. Thank you. Test script: --------------- <?php $the_date = new DateTime(); $the_date->setTime(0, 0, 0); $the_date->SetDate(20201, 01, 01); var_dump($the_date); $serialized = serialize($the_date); var_dump($serialized); var_dump(unserialize($serialized)); Actual result: -------------- /home/nico/test/unserialize.php:7: class DateTime#1 (3) { public $date => string(27) "20201-01-01 00:00:00.000000" public $timezone_type => int(3) public $timezone => string(13) "Europe/Berlin" } /home/nico/test/unserialize.php:10: string(126) "O:8:"DateTime":3:{s:4:"date";s:27:"20201-01-01 00:00:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:13:"Europe/Berlin";}" PHP Fatal error: Uncaught Error: Invalid serialization data for DateTime object in /home/nico/test/unserialize.php:11 Stack trace: #0 [internal function]: DateTime->__wakeup() #1 /home/nico/test/unserialize.php(11): unserialize('O:8:"DateTime":...') #2 {main} thrown in /home/nico/test/unserialize.php on line 11