Home > Article > Backend Development > Yii2 format date problem
has been set up timeZone
, but formatting with Formatter
does not work, it is still in English format.
<code class="php">'timeZone' => 'Asia/Shanghai' dd( date_default_timezone_get(), Yii::$app->getTimeZone(), Yii::$app->formatter->timeZone, Yii::$app->formatter->asDate('2016-05-15'), date('Y-m-d H:i:s') );</code>
Server Output:
<code>"Asia/Shanghai" "Asia/Shanghai" "Asia/Shanghai" "May 15, 2016" "2016-06-16 15:54:53"</code>
Local is good:
<code>"Asia/Shanghai" "Asia/Shanghai" "Asia/Shanghai" "2016年5月15日" "2016-06-16 15:54:45"</code>
Why is this~
Server php 5.5.9
Local php 5.6.11
has been set up timeZone
, but formatting with Formatter
does not work, it is still in English format.
<code class="php">'timeZone' => 'Asia/Shanghai' dd( date_default_timezone_get(), Yii::$app->getTimeZone(), Yii::$app->formatter->timeZone, Yii::$app->formatter->asDate('2016-05-15'), date('Y-m-d H:i:s') );</code>
Server Output:
<code>"Asia/Shanghai" "Asia/Shanghai" "Asia/Shanghai" "May 15, 2016" "2016-06-16 15:54:53"</code>
Local is good:
<code>"Asia/Shanghai" "Asia/Shanghai" "Asia/Shanghai" "2016年5月15日" "2016-06-16 15:54:45"</code>
Why is this~
Server php 5.5.9
Local php 5.6.11
This should have nothing to do with the php
version. Please check whether the format of the configuration time parameter in your configuration file is different