Bug #78578 [NEW]: Parsing of DateTime strings is VERY inconsistent

From: Date: Sat, 21 Sep 2019 09:03:18 +0000
Subject: Bug #78578 [NEW]: Parsing of DateTime strings is VERY inconsistent
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222853@lists.php.net to get a copy of this message
From: danielklein at airpost dot net Operating system: Windows 10 PHP version: 7.3.9 Package: Date/time related Bug Type: Bug Bug description:Parsing of DateTime strings is VERY inconsistent Description: ------------ --- From manual page: https://php.net/datetime.formats.date --- Parsing the DateTime string '24.6.08' gives 6 minutes and 8 seconds past the end of today (the start of tomorrow). Parsing the DateTime string '25.6.08' gives midnight at the start of 25 June 2008. That is so inconsistent it's impossible to work out which one, if either, is correct. I've also asked a question on Stack Overflow about the weird behaviour of the DateTime string parser with many other examples. https://stackoverflow.com/q/58038176/1166898 Test script: --------------- var_dump(new DateTime('24.6.08')); var_dump(new DateTime('25.6.08')); Expected result: ---------------- I have no idea. I just know what it does output is very wrong. They should both be dates, or both be interpreted as times with hour 25 throwing an error (maybe hour 24 throwing an error too), or both be errors, or something else consistent with each other. Actual result: -------------- class DateTime#1 (3) { public $date => string(26) "2019-09-22 00:06:08.000000" public $timezone_type => int(3) public $timezone => string(3) "UTC" } class DateTime#1 (3) { public $date => string(26) "2008-06-25 00:00:00.000000" public $timezone_type => int(3) public $timezone => string(3) "UTC" } -- Edit bug report at https://bugs.php.net/bug.php?id=78578&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78578&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78578&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78578&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78578&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78578&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78578&r=support Expected behavior: https://bugs.php.net/fix.php?id=78578&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78578&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78578&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78578&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78578&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78578&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78578&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78578&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78578&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78578&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78578&r=mysqlcfg

« previous php.bugs (#222853) next »