yii框架中,可以直接在/protected/config/main.php中设置时区,即可(补充:Yii2方法也是一样,在common/config/main.php中添加)。 (推荐学习:yii教程)
在config文件夹下,main.php 中,
return [ 'charset' => 'utf-8', 'language' => 'zh-CN', 'timeZone' => 'Asia/Shanghai', 'components' => [ 'cache' => [ 'class' => 'yiicachingFileCache' ], 'formatter' => [ 'dateFormat' => 'yyyy-MM-dd', 'timeFormat' => 'HH:mm:ss', 'datetimeFormat' => 'yyyy-MM-dd HH:mm:ss' ] ] ];