php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80831 IntlDateFormatter considers January 2021 days to be January 2020 days
Submitted: 2021-03-04 16:12 UTC Modified: 2021-03-04 16:21 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: sebastian@php.net Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 8.0.3RC1 OS: Irrelevant
Private report: No CVE-ID: None
 [2021-03-04 16:12 UTC] sebastian@php.net
Description:
------------
I have DateTimeImmutable objects representing days/dates in January 2021. When I format these objects using an IntlDateFormatter object with the "MMMM Y" formatting string then the first three days of January 2021 are printed as January 2020.

Test script:
---------------
<?php declare(strict_types=1);
$formatter = new IntlDateFormatter(
    'de_DE',
    IntlDateFormatter::FULL,
    IntlDateFormatter::FULL,
    'Europe/Berlin',
    IntlDateFormatter::GREGORIAN,
    'MMMM Y'
);

var_dump($formatter->format(new DateTimeImmutable('2021-01-01')));
var_dump($formatter->format(new DateTimeImmutable('2021-01-02')));
var_dump($formatter->format(new DateTimeImmutable('2021-01-03')));
var_dump($formatter->format(new DateTimeImmutable('2021-01-04')));


Expected result:
----------------
string(11) "Januar 2021"
string(11) "Januar 2021"
string(11) "Januar 2021"
string(11) "Januar 2021"


Actual result:
--------------
string(11) "Januar 2020"
string(11) "Januar 2020"
string(11) "Januar 2020"
string(11) "Januar 2021"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-04 16:20 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2021-03-04 16:20 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

There is a difference between a natural year and an ISO year, and I think "Y" is the ISO year (belonging to full ISO weeks and days) in Intl speak, I think. You want just "y".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 04:01:30 2024 UTC