Home > Article > Backend Development > Yii2 set time zone
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',