Bug #64975 [Opn->Ana]: createFromFormat Error parsing when AM PM not at the end
| From: | daverandom@php.net | Date: | Fri, 09 May 2014 20:38:52 +0000 |
| Subject: | Bug #64975 [Opn->Ana]: createFromFormat Error parsing when AM PM not at the end | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185746@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64975&edit=1
ID: 64975
Updated by: daverandom@php.net
Reported by: dimka212 at gmail dot com
Summary: createFromFormat Error parsing when AM PM not at the
end
-Status: Open
+Status: Analyzed
Type: Bug
Package: Date/time related
-Operating System: Windows
+Operating System: Any
PHP Version: Irrelevant
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2014-05-09 12:20:03] daverandom@php.net
This behaviour is not in itself a bug.
The issue is that the wrong error is reported, and the root cause of this is actually a bug in the
way date_get_last_errors() works rather than the date parsing mechanism.
As fixing this would be a BC break, I have submitted a patch that ensures that in this specific case
the correct error is reported.
------------------------------------------------------------------------
[2013-06-05 11:16:16] dimka212 at gmail dot com
Description:
------------
$date = DateTime::createFromFormat('d M Y A h:i', '11 Mar 2013 PM 3:34');
Returns: [12] => Unexpected data found.
Works only in this case:
$date = DateTime::createFromFormat('d M Y h:i A', '11 Mar 2013 3:34 PM');
Test script:
---------------
$date = DateTime::createFromFormat('d M Y A h:i', '11 Mar 2013 PM 3:34');
if(!$date) echo 'Doesn\'t work =(';
Expected result:
----------------
Returns DateTime object
Actual result:
--------------
False
(Unexpected data found.)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64975&edit=1