Bug #66836 [Opn->Ver]: DateTime::createFromFormat 'U' with pre 1970 dates fails parsing
| From: | cmb@php.net | Date: | Mon, 11 Jul 2016 12:35:06 +0000 |
| Subject: | Bug #66836 [Opn->Ver]: DateTime::createFromFormat 'U' with pre 1970 dates fails parsing | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202194@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66836&edit=1
ID: 66836
Updated by: cmb@php.net
Reported by: rami dot alnawas at gmail dot com
-Summary: DateTime::createFromFormat 'U' with pre 1970 dates,
fails parsing
+Summary: DateTime::createFromFormat 'U' with pre 1970 dates
fails parsing
-Status: Open
+Status: Verified
Type: Bug
Package: Date/time related
Operating System: Ubuntu
PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
I can confirm the issue, see <https://3v4l.org/mT3CX>.
However, it
has recently been fixed in master[1], and might be backported.
[1] <https://github.com/php/php-src/commit/822ca45220db0b864af9dc79b94bda03a9323621>
Previous Comments:
------------------------------------------------------------------------
[2014-03-06 14:29:22] rami dot alnawas at gmail dot com
Description:
------------
When DateTime::createFromFormat('U', strtotime('1962-11-17T00:00:00+00:00') is
executed the result is false as strtotime('1962-11-17T00:00:00+00:00') is negative.
Using date function with the same input works OK
Test script:
---------------
echo date('YmdHis', strtotime('1962-11-17T00:00:00+00:00')); // 19621117000000
print_r(DateTime::createFromFormat('U', strtotime('1962-11-17T00:00:00+00:00'),
new \DateTimeZone('UTC'))->format('YmdHis')); // fails as createFromFormat
returns false
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66836&edit=1