Home > Backend Development > PHP Tutorial > Yii2 set time zone

Yii2 set time zone

WBOY
Release: 2016-08-08 09:20:40
Original
1686 people have browsed it

Time zone, during development, if you say it is important, it is okay, after all, it can run normally without it. If you say it is not important, then it will be tangled. Especially for Linux systems, the difference is just a few hours. Can you not be in pain? Win is a little better.
There are some common methods that everyone is currently using
1. Settings in php.ini, I won’t talk about this.
2. Settings in the public files in the program, date_default_timezone_set the time zone
3. Or. . . Write your own time processing function, and use this function to process when you encounter time (I prefer to use this method. If your users come from all over the world, it may be useful)
4. In the yii framework, you can directly Just add timeZone to /protected/config/main.php (Supplement: The Yii2 method is the same, add it to common/config/main.php)

'timeZone'=>'Asia/Chongqing' ,

The above introduces how to set the time zone in Yii2, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

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