2

I have problem with using Yii2-formatter. My config is

    'formatter' => [
        'class' => 'yii\i18n\Formatter',
        'defaultTimeZone' => 'Asia/Novosibirsk',
        'timeZone' => 'Asia/Novosibirsk',
        'currencyCode' => 'RUB',
        'locale' => 'ru_RU',
        'dateFormat' => 'php:d.m.Y',
        'timeFormat' => 'php: H:i:s',
        'datetimeFormat' => 'php:d.m.Y H:i',
    ],

When I try

echo Yii::$app->formatter->asDateTime('15-06-2014 14:10:10');

it work correct - show 15.06.2014 14:10. When I try

echo Yii::$app->formatter->asDateTime('15-06-2015 14:10:10');

it work not correct - show 15.06.2015 15:10. When I set year 2016, it works not corrected too. I try to

echo date('d.m.Y H:i', strtotime('15-06-2015 14:10:10'))

And it works correct for 2015 and 2016 years, PHP-config is right. Could anyone help, what's wrong with my code?

1 Answer 1

2

I think it's related with returning to standard time all year in Russia in 2014 year (October, 26). See this article for reference:

Most Russians will move to permanent Standard Time, or “winter time”, by setting their clocks 1 hour back on October 26, 2014. This is the same date most Europeans end Daylight Saving Time (DST).

Check you date.timezone setting in php.ini config and PHP version used, seems like it was fixed in later versions.

Also check tzdata and pecl timezonedb.

Maybe this forum discussion will be helpful too, even it's in russian.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.