|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74597 IntlDateFormatter::parse incorrect behavior on month
Submitted: 2017-05-15 12:37 UTC Modified: 2017-05-16 08:14 UTC
From: shubinmi at gmail dot com Assigned:
Status: Closed Package: intl (PECL)
PHP Version: 5.6.30 OS: CentOS 7.1
Private report: No CVE-ID: None
 [2017-05-15 12:37 UTC] shubinmi at gmail dot com
IntlDateFormatter::parse has incorrect behavior for mounth. I waiting for error when month is more then 12, but now it returns date of next year.

Test script:
$formatter = new \IntlDateFormatter('en_US', \IntlDateFormatter::NONE, \IntlDateFormatter::NONE,'UTC', null, 'Y-m-d');
$parsedDate = $formatter->parse('1981-15-21');
if ($parsedDate === false) {
 echo 'success';
} else {
 echo 'fail';

// return "fail"

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-15 14:56 UTC] andrew dot nester dot dev at gmail dot com
Here you can see that `m` stands for minute in an hour, but `M` for month.

If you will use M in your pattern, you will receive false value.

maybe this behaviour requires some documentation?
 [2017-05-16 08:14 UTC] shubinmi at gmail dot com
-Status: Open +Status: Closed
 [2017-05-16 08:14 UTC] shubinmi at gmail dot com
Thank you! Sorry that took your time. It's my false by inattention.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Sep 23 12:01:27 2023 UTC