psylosss
psylosss

Reputation: 3529

Why PHP IntlDateFormatter returns wrong date? +1 hour

When I try to format date from one timezone to same timezone I get wrong time (differenced by 1 hour). My code is:

$formatter = new IntlDateFormatter(
    'ru_RU',
    IntlDateFormatter::FULL,
    IntlDateFormatter::FULL,
    'Europe/Moscow'
);

$date = new DateTime("2015-07-29 14:00:00", new DateTimeZone('Europe/Moscow'));
echo $formatter->format($date);

Expected time is 14:00, but 15:00 returns.

UPDATE: When I display year 2013 or 2014 everything is ok! What happens in 2015?

UPDATE2: +1 hour added from 26 october 2014. Its time when Russia goes to eternal winter time. Ok. But... how to format correctly?

Upvotes: 6

Views: 1125

Answers (3)

Serge Kraev
Serge Kraev

Reputation: 39

I use directly 'GMT+03:00' instead 'Europe/Moscow'. Apparently the developers of the library do not have time for lawmakers.

Upvotes: 3

psylosss
psylosss

Reputation: 3529

If you have same problem, update icu (International Components for Unicode) at your OS.

Upvotes: 2

AlexARH
AlexARH

Reputation: 212

Check your php.ini file for date.timezone and make sure its set to

date.timezone = "Europe/Moscow"

Upvotes: 0

Related Questions