Bug #77745 [NEW]: Unexpected result DateTime::createFromFormat

From: Date: Thu, 14 Mar 2019 20:51:47 +0000
Subject: Bug #77745 [NEW]: Unexpected result DateTime::createFromFormat
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219968@lists.php.net to get a copy of this message
From: dnkonev at yandex dot ru Operating system: Ubuntu 18.04.1 LTS PHP version: 7.1.27 Package: Date/time related Bug Type: Bug Bug description:Unexpected result DateTime::createFromFormat Description: ------------ --- From manual page: https://php.net/datetime.createfromformat --- PHP VER: PHP 7.1.26-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Jan 11 2019 14:13:49) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.1.26-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans When I use "Y" as the first argument and pass the value of two numbers as the second argument, function executed without errors and returns a DateTime object. Year in this DateTime object takes the value "00 + two numbers that I have passed" Test script: --------------- <?php $a = \DateTime::createFromFormat('m/d/Y', '12/31/29'); echo $a->format('Y-m-d') . PHP_EOL; $a = \DateTime::createFromFormat('Y', '10'); echo $a->format('Y-m-d') . PHP_EOL; -- Edit bug report at https://bugs.php.net/bug.php?id=77745&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77745&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77745&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77745&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77745&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77745&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77745&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77745&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77745&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77745&r=support Expected behavior: https://bugs.php.net/fix.php?id=77745&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77745&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77745&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77745&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77745&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77745&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77745&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77745&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77745&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77745&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77745&r=mysqlcfg

« previous php.bugs (#219968) next »