|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-03-11 09:27 UTC] ignasi35 at gmail dot com
Description: ------------ --- From manual page: http://www.php.net/book.intl --- When requesting IntlDateFormatter to format '2016-01-03' using a specific set of locales with pattern 'YYYY' it returns 2015. Steps to reproduce: - See attached code. Details: - only some locales fail - we reproduce the error for dates 2016-01-01, 2016-01-02 and 2016-01-03. It looks like 2016-01-04 triggers the correct output - So far, for '2016-01-03' these values fail/pass: $locale = 'en_UK' ; // UK -> passes $locale = 'en_US' ; // US -> passes $locale = 'ru_RU'; // Russian -> passes $locale = 'es_ES'; // Spanish -> fails $locale = 'de_DE'; // German -> fails $locale = 'el_GR'; // Greek -> fails - we use the date '2016-01-03' to rule out a TZ-offset issue - we tested successfully Russia (ahead of UTC), UK (in UTC) and US (behind UTC) - we found Germany and Spain to fail (both in CET), But also Greece (not in CET) This could be a side effect of https://bugs.php.net/bug.php?id=65694. Test script: --------------- <?php $locale = 'en_US' ; // US -> passes $locale = 'ru_RU'; // Russian -> passes $locale = 'es_ES'; // Spanish -> fails $locale = 'de_DE'; // German -> fails $locale = 'el_GR'; // Greek -> fails setlocale(LC_ALL, $locale ); echo "$locale \n" ; $DEFAULT_ZONE = 'Europe/Madrid'; $humantime = "2016-01-03" ; $time = strtotime($humantime) ; echo "humantime: $humantime \n" ; echo "time: $time \n" ; $pattern = ' YYYY'; $fmt = new IntlDateFormatter( $locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE, $DEFAULT_ZONE, IntlDateFormatter::GREGORIAN, $pattern); echo $fmt->format($time); Expected result: ---------------- We expected the result to be '2016' Actual result: -------------- The output is 2015 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 20:00:01 2025 UTC |
This is not a bug. The week in year ('YYYY') depends no the locale, I should have used 'yyyy'