Open the main.php file and configure it as follows:
(Recommended tutorial: yii framework)
return [ 'charset' => 'utf-8', 'language' => 'zh-CN', 'timeZone' => 'Asia/Shanghai', 'components' => ['formatter' => [ 'dateFormat' => 'yyyy-MM-dd', 'timeFormat' => 'HH:mm:ss', 'datetimeFormat' => 'yyyy-MM-dd HH:mm:ss' ] ] ];
More For programming-related content, please pay attention to the Introduction to Programming column on the php Chinese website!
The above is the detailed content of How to set the time zone in yii2.0. For more information, please follow other related articles on the PHP Chinese website!