php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75078 IntlDateFormatter displays wrong dates, off by a year (!)
Submitted: 2017-08-16 16:02 UTC Modified: 2017-08-16 17:44 UTC
From: f dot bosch at genkgo dot nl Assigned: cmb (profile)
Status: Not a bug Package: intl (PECL)
PHP Version: 7.2.0beta2 OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: f dot bosch at genkgo dot nl
New email:
PHP Version: OS:

 

 [2017-08-16 16:02 UTC] f dot bosch at genkgo dot nl
Description:
------------
When formatting dates around the year ending IntlDateFormatter produces wrong outputs. Not just unexpected for the locale, but wrong values. More precisely: it is off by a year. This was already reported in #73405.


A. Formatting 2017-12-31 12:00:00. In this case en_US is wrong, off by a year.

Using: en_US, Europe/London, "Y".
- Result: 2018. Expected: 2017. 3v4l: https://3v4l.org/mIUue.

Using: en_US, Europe/London, "Y-MM-dd".
- Result: 2018-12-31. Expected: 2017-12-31. 3v4l: https://3v4l.org/sMO9K.

Using: nl_NL, Europe/Amsterdam, "Y".
- Result: 2017. Expected: 2017. 3v4l: https://3v4l.org/6TJ4R.

Using: nl_NL, Europe/London, "Y".
- Result: 2017. Expected: 2017. 3v4l: https://3v4l.org/NdjNM.


B. Formatting 2017-01-01 12:00:00. In this case nl_NL is wrong, off by a year.

Using: nl_NL, Europe/Amsterdam, "Y-MM-dd".
- Result: 2016-01-01. Expected: 2017-01-01. 3v4l: https://3v4l.org/oeWEb.

Using: en_US, Europe/London, "Y-MM-dd".
- Result: 2017-01-01. Expected: 2017-01-01. 3v4l: https://3v4l.org/7ibRK.

Test script:
---------------
<?php

$formatter = new IntlDateFormatter(
    'en_US',
    IntlDateFormatter::FULL,
    IntlDateFormatter::FULL,
    'Europe/London',
    IntlDateFormatter::GREGORIAN,
    "Y-MM-dd"
);


echo $formatter->format(
    new DateTime('2017-12-31 12:00:00', new DateTimeZone('Europe/London'))
);

Expected result:
----------------
2017-12-31

Actual result:
--------------
2018-12-31

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-08-16 17:28 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2017-08-16 17:28 UTC] cmb@php.net
`Y` is supposed to show the year of "Week of Year". To get simply
the year, use 'y'. See also
<http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Field-Symbol-Table>.
 [2017-08-16 17:44 UTC] f dot bosch at genkgo dot nl
Damn, sorry guys. Please close!
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun May 11 13:01:28 2025 UTC