|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-03-16 12:53 UTC] derick@php.net
-Status: Open
+Status: Not a bug
[2020-03-16 12:53 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 09:00:01 2025 UTC |
Description: ------------ Incorrect creation from incorrect dates with DateTimeImmutable::createFromFormat Test script: --------------- try{ $date = '2021-31-31'; $date1 = \DateTimeImmutable::createFromFormat('Y-m-d', $date); var_dump($date1); $date2 = new \DateTimeImmutable($date); }catch (\Throwable $e){ var_dump($e->getMessage()); } die; Expected result: ---------------- Failed to parse time string (2021-31-31) at position 6 (6): Unexpected character Actual result: -------------- php version 7.4.2 class DateTimeImmutable#905 (0) { } sometimes it's even such: DateTimeImmutable @1690803734 {#905 date: 2023-07-31 11:42:14.0 UTC (+00:00) } php version 7.4.3 object(DateTimeImmutable)#985 (3) { ["date"]=> string(26) "2023-07-31 14:26:58.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(15) "Europe/Helsinki" }