Bug #75992 [NEW]: DateTime::createFromString() does not work with years > 4 digits
| From: | dktapps at pmmp dot io | Date: | Thu, 22 Feb 2018 10:23:52 +0000 |
| Subject: | Bug #75992 [NEW]: DateTime::createFromString() does not work with years > 4 digits | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-214064@lists.php.net to get a copy of this message | ||
From: dktapps at pmmp dot io
Operating system: Windows 10
PHP version: 7.2.2
Package: Date/time related
Bug Type: Bug
Bug description:DateTime::createFromString() does not work with years > 4 digits
Description:
------------
DateTime formats can be created using format() which have >4 digits in
the year, which cannot be parsed using createFromFormat() with the same
format-string. As seen below the same format is used both times.
This bug report looks absurd, but I've had similar issues been
auto-reported to my crash archive when users put absurd values in
configuration, and this appears to be why.
Test script:
---------------
<?php
$datetime = new \DateTime('@' . PHP_INT_MAX);
$str = $datetime->format("Y-m-d H:i:s O");
var_dump($str); //275808-11-04 10:06:43 +0000
var_dump(\DateTime::createFromFormat("Y-m-d H:i:s O", $str));
//bool(false)
?>
Expected result:
----------------
Either:
bool(false)
bool(false)
OR
string(33) "292277026596-12-04 15:30:07 +0000
object(DateTime)#2 (3) {
["date"]=>
string(34) "292277026596-12-04 15:30:07.000000
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+00:00"
}
Actual result:
--------------
string(33) "292277026596-12-04 15:30:07 +0000"
bool(false)
--
Edit bug report at https://bugs.php.net/bug.php?id=75992&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75992&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75992&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75992&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75992&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75992&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75992&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75992&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75992&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75992&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75992&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75992&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75992&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75992&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75992&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75992&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75992&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75992&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75992&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75992&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75992&r=mysqlcfg