Home > Backend Development > PHP Tutorial > Yii2 format date problem

Yii2 format date problem

WBOY
Release: 2016-07-06 13:53:15
Original
1166 people have browsed it

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>
Copy after login
Copy after login

Server Output:

<code>"Asia/Shanghai"

"Asia/Shanghai"

"Asia/Shanghai"

"May 15, 2016"

"2016-06-16 15:54:53"</code>
Copy after login
Copy after login

Local is good:

<code>"Asia/Shanghai"

"Asia/Shanghai"

"Asia/Shanghai"

"2016年5月15日"

"2016-06-16 15:54:45"</code>
Copy after login
Copy after login

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>
Copy after login
Copy after login

Server Output:

<code>"Asia/Shanghai"

"Asia/Shanghai"

"Asia/Shanghai"

"May 15, 2016"

"2016-06-16 15:54:53"</code>
Copy after login
Copy after login

Local is good:

<code>"Asia/Shanghai"

"Asia/Shanghai"

"Asia/Shanghai"

"2016年5月15日"

"2016-06-16 15:54:45"</code>
Copy after login
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template