Bug #74482 [Com]: Missing validation of date in DateTime::createFromFormat

From: Date: Thu, 20 Apr 2017 15:06:21 +0000
Subject: Bug #74482 [Com]: Missing validation of date in DateTime::createFromFormat
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208686@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74482&edit=1 ID: 74482 Comment by: php-bugs at allenjb dot me dot uk Reported by: spam at bugyik dot cz Summary: Missing validation of date in DateTime::createFromFormat Status: Open Type: Bug Package: Date/time related Operating System: Linux PHP Version: 7.1.4 Block user comment: N Private report: N New Comment: DateTime has an internal warnings system it uses which you can use to detect invalid dates - see DateTime::getLastErrors(): https://3v4l.org/8IBbL Previous Comments: ------------------------------------------------------------------------ [2017-04-20 15:01:32] spam at bugyik dot cz Description: ------------ I'm missing validation of date-time in DateTime::createFromFormat. The example below tells more. Test script: --------------- <?php var_dump(\DateTime::createFromFormat(\DateTime::RFC3339, '2017-99-99T08:51:13-03:00')); Expected result: ---------------- some exception expected (like from new DateTime('bad-time')) Actual result: -------------- object(DateTime)#1 (3) { ["date"]=> string(26) "2025-06-07 08:51:13.000000" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "-03:00" } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74482&edit=1

« previous php.bugs (#208686) next »