|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-08-21 08:10 UTC] justmoen at gmail dot com
-Summary: IntlDateFormatter not parsing from given format
+Summary: IntlDateFormatter not parsing from given format for
some locales
[2019-08-21 08:10 UTC] justmoen at gmail dot com
[2019-08-21 13:25 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
-Package: Date/time related
+Package: intl
[2019-08-21 13:25 UTC] requinix@php.net
[2019-08-21 14:49 UTC] justmoen at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 01:00:02 2025 UTC |
Description: ------------ IntlDateFormatter appears to treat the provided pattern parameter 'MM/dd/yyyy h:mm: a' as invalid based on the given culture. The problem occurs after a change in ICU 64.1 to no longer accept am/pm for cultures with the languages 'es', 'sv' and several others. Should the IntlDateFormatter be able to parse from a standard pattern independent of the set locale? Test script: --------------- <?php $date = '08/08/2019 06:00 pm'; $cultureZones = [ 'en_US' => 'US/Central', 'es_US' => 'US/Central', 'fr_CA' => 'Canada/Central', 'en_CA' => 'Canada/Central', 'es_ES' => 'Europe/Madrid', 'en_GB' => 'Europe/London', 'es_MX' => 'America/Mexico_City', 'fr_FR' => 'Europe/Paris', 'sv_SE' => 'Europe/Stockholm' ]; foreach($cultureZones as $culture => $timezone) { $formatter = new \IntlDateFormatter($culture, 2, 2, $timezone, 1, 'MM/dd/yyyy h:mm a'); echo $culture." (".$timezone.") returned: ".var_export( $formatter->parse($date), true )."\n"; } Expected result: ---------------- en_US (US/Central) returned: 1565305200 es_US (US/Central) returned: 1565305200 fr_CA (Canada/Central) returned: 1565305200 en_CA (Canada/Central) returned: 1565305200 es_ES (Europe/Madrid) returned: 1565280000 en_GB (Europe/London) returned: 1565283600 es_MX (America/Mexico_City) returned: 1565305200 fr_FR (Europe/Paris) returned: 1565280000 sv_SE (Europe/Stockholm) returned: 1565280000 Actual result: -------------- en_US (US/Central) returned: 1565305200 es_US (US/Central) returned: false fr_CA (Canada/Central) returned: 1565305200 en_CA (Canada/Central) returned: 1565305200 es_ES (Europe/Madrid) returned: false en_GB (Europe/London) returned: 1565283600 es_MX (America/Mexico_City) returned: false fr_FR (Europe/Paris) returned: 1565280000 sv_SE (Europe/Stockholm) returned: false