Home  >  Article  >  Backend Development  >  Yii2 set time zone

Yii2 set time zone

巴扎黑
巴扎黑Original
2016-11-10 13:40:451142browse

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 suffer? 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 use / 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',


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