Bug #76731 [NEW]: Date time format parsing is wrong for format Ynd
| From: | remy dot fox at simbuka dot com | Date: | Sun, 12 Aug 2018 12:21:27 +0000 |
| Subject: | Bug #76731 [NEW]: Date time format parsing is wrong for format Ynd | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-216730@lists.php.net to get a copy of this message | ||
From: remy dot fox at simbuka dot com
Operating system:
PHP version: 7.2.8
Package: Date/time related
Bug Type: Bug
Bug description:Date time format parsing is wrong for format Ynd
Description:
------------
The parsing of the date formats 'Ynd' and 'Ymd' gives a wrong result
when segment in the date are not separated by any characters.
There may be similar issues with other date time format specifier
combinations too, but I haven't tested them.
Test script:
---------------
$date = DateTime::createFromFormat("Ymd", "2000-10-1");
var_dump($date);
$date = DateTime::createFromFormat("Ymd", "2000101");
var_dump($date);
Expected result:
----------------
As we can see, the first $date returns false, which is correct. After
all the day value was not padded with a zero. In the second example, the
zero could be interpreted as either part of the month (i.e. october) or
as padding for the day value. The result does not return false but it
should.
object(DateTime)#2 (3) {
["date"]=>
string(26) "2000-10-01 05:18:02.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(10) "US/Pacific"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=76731&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76731&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76731&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76731&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76731&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76731&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76731&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76731&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76731&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76731&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76731&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76731&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76731&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76731&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76731&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76731&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76731&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76731&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76731&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76731&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76731&r=mysqlcfg