Bug #78432 [NEW]: IntlDateFormatter not parsing from given format

From: Date: Wed, 21 Aug 2019 07:53:27 +0000
Subject: Bug #78432 [NEW]: IntlDateFormatter not parsing from given format
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222333@lists.php.net to get a copy of this message
From: justmoen at gmail dot com Operating system: Ubuntu 16.04 PHP version: 7.2.21 Package: Date/time related Bug Type: Bug Bug description:IntlDateFormatter not parsing from given format 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 -- Edit bug report at https://bugs.php.net/bug.php?id=78432&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78432&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78432&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78432&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78432&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78432&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78432&r=support Expected behavior: https://bugs.php.net/fix.php?id=78432&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78432&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78432&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78432&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78432&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78432&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78432&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78432&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78432&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78432&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78432&r=mysqlcfg

« previous php.bugs (#222333) next »