yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.9k forks source link

The problem with the timeZone #10228

Closed evgenmil closed 8 years ago

evgenmil commented 8 years ago

Hello. The time now is (in fact) 17:30 Current time zone (in fact) GMT +05: 00

Simple file:

<?php
date_default_timezone_set("Asia/Yekaterinburg");
echo date(DATE_RFC2822);

returns Mon, 23 Nov 2015 17:30:35 +0500

Output the through yii2:

Yii::$app->setTimeZone("Asia/Yekaterinburg");
echo Yii::$app->formatter->asDatetime(time(), 'long');

returns 23 ноября 2015 г., 18:30:35 GMT+06:00

phpinfo(): PHP Version 5.4.45 date/time support — enabled "Olson" Timezone Database Version — 2015.7 Internationalization support — enabled version — PECL-3.0.0 ICU version — 50.1.2 ICU Data version — 50.1

Tell me, please, what's the problem? Why through yii2 +06? Thank you.

SilverFire commented 8 years ago

Failed to reproduce on basic app template

date_default_timezone_set("Asia/Yekaterinburg");
echo date(DATE_RFC2822);

echo "<br />";

Yii::$app->setTimeZone("Asia/Yekaterinburg");
echo Yii::$app->formatter->asDatetime(time(), 'long');

returns

Mon, 23 Nov 2015 19:27:45 +0500
23 ноября 2015 г., 19:27:45 GMT+5

PHP Version 5.6.11-1ubuntu3.1 date/time support — enabled "Olson" Timezone Database Version — 0.system Timezone Database — internal Default timezone — Asia/Yekaterinburg

Internationalization support — enabled version — 1.1.0 ICU version — 55.1 ICU Data version — 55.1

cebe commented 8 years ago

@evgenmil seems the timezone database in your intl library is outdated...

cebe commented 8 years ago

http://www.yiiframework.com/doc-2.0/guide-tutorial-i18n.html#setup-environment

Additionally the information in the time zone database shipped with the ICU library may be outdated. Please refer to the ICU manual for details on updating the time zone database. While for output formatting the ICU timezone database is used, the time zone database used by PHP may be relevant too. You can update it by installing the latest version of the pecl package timezonedb.

evgenmil commented 8 years ago

Thanks

evgenmil commented 8 years ago

that is, it is directly dependent on my version of ICU 50.1.2