Home  >  Article  >  Backend Development  >  Yii2 format date problem

Yii2 format date problem

WBOY
WBOYOriginal
2016-07-06 13:53:151143browse

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

Reply content:

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn