|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-07-08 13:05 UTC] johannes@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: stas
[2010-07-08 13:05 UTC] johannes@php.net
[2010-09-01 23:52 UTC] stas@php.net
-Status: Assigned
+Status: Bogus
[2010-09-01 23:52 UTC] stas@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 04:00:01 2025 UTC |
Description: ------------ Parsing a value with YYYY in the pattern returns unexpected results. Formatting the value using the YYYY in the pattern works perfect. Test script: --------------- $fmt = new IntlDateFormatter('lt_LT', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'Europe/Vilnius', IntlDateFormatter::GREGORIAN); $value = '2007-10-01'; // notice, that 2007-01-01 equals to 2007-W01-1 $variants = array(); $fmt->setPattern('yyyy'); $pts = $fmt->parse($value); $variants[] = array($pts, $fmt->format($pts)); $fmt->setPattern('yyyy-MM'); $pts = $fmt->parse($value); $variants[] = array($pts, $fmt->format($pts)); $fmt->setPattern('yyyy-MM-dd'); $pts = $fmt->parse($value); $variants[] = array($pts, $fmt->format($pts)); $fmt->setPattern('YYYY'); $pts = $fmt->parse($value); $variants[] = array($pts, $fmt->format($pts)); $fmt->setPattern('YYYY-MM'); $pts = $fmt->parse($value); $variants[] = array($pts, $fmt->format($pts)); $fmt->setPattern('YYYY-MM-dd'); $pts = $fmt->parse($value); $variants[] = array($pts, $fmt->format($pts)); print_r($variants); Expected result: ---------------- array ( 0 => array ( 0 => 1167602400, 1 => '2007', ), 1 => array ( 0 => 1191186000, 1 => '2007-10', ), 2 => array ( 0 => 1191186000, 1 => '2007-10-01', ), 3 => array ( 0 => 1167602400, 1 => '2007', ), 4 => array ( 0 => 1191186000, 1 => '2007-10', ), 5 => array ( 0 => 1191186000, 1 => '2007-10-01', ), ) Actual result: -------------- array ( 0 => array ( 0 => 1167602400, 1 => '2007', ), 1 => array ( 0 => 1191186000, 1 => '2007-10', ), 2 => array ( 0 => 1191186000, 1 => '2007-10-01', ), 3 => array ( 0 => 1166997600, 1 => '2006', ), 4 => array ( 0 => 1166997600, 1 => '2006-12', ), 5 => array ( 0 => 23576400, 1 => '1970-10-01', ), )