Bug #79926 [Opn]: `DateTime::createFromFormat`: `H` overflows to next same *weekday* for D-format

From: Date: Mon, 03 Aug 2020 20:25:17 +0000
Subject: Bug #79926 [Opn]: `DateTime::createFromFormat`: `H` overflows to next same *weekday* for D-format
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228395@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79926&edit=1 ID: 79926 User updated by: thomas at landauer dot at Reported by: thomas at landauer dot at Summary: DateTime::createFromFormat: H overflows to next same *weekday* for D-format Status: Open Type: Bug Package: Date/time related Operating System: Linux PHP Version: 7.2.32 Block user comment: N Private report: N New Comment: My actual PHP version is 7.2.24 Previous Comments: ------------------------------------------------------------------------ [2020-08-03 20:23:12] thomas at landauer dot at Description: ------------ As I learned from https://bugs.php.net/bug.php?id=67921 it is the expected behavior for an hour between 24 and 99 to just overflow to the next day: var_dump(DateTime::createFromFormat('H:m', '25:00')); gives me tomorrow at 01:00 - that's OK. However, if I use one of the formats that start with 'D', the hour doesn't overflow to the next day, but to the next (e.g.) *Monday* (i.e. same weekday of the next week): Test script: --------------- var_dump(DateTime::createFromFormat(DateTime::RFC822, 'Mon, 3 Aug 20 25:00:00 +0000')); var_dump(DateTime::createFromFormat(DateTime::RFC1036, 'Mon, 3 Aug 20 25:00:00 +0000')); var_dump(DateTime::createFromFormat(DateTime::RFC1123, 'Mon, 3 Aug 20 25:00:00 +0000')); var_dump(DateTime::createFromFormat(DateTime::RFC7231, 'Mon, 3 Aug 20 25:00:00 GMT')); var_dump(DateTime::createFromFormat(DateTime::RFC2822, 'Mon, 3 Aug 2020 25:00:00 +0000')); var_dump(DateTime::createFromFormat(DateTime::RSS, 'Mon, 3 Aug 2020 25:00:00 +0000')); Expected result: ---------------- 4 Aug 2020 01:00 Actual result: -------------- 10 Aug 2020 01:00 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79926&edit=1

« previous php.bugs (#228395) next »