Home  >  Article  >  PHP Framework  >  Where to set the time zone in yii2

Where to set the time zone in yii2

(*-*)浩
(*-*)浩Original
2019-12-30 11:40:503671browse

Where to set the time zone in yii2

In the yii framework, you can set the time zone directly in /protected/config/main.php (Additional: The same is true for Yii2 method, in common/config/main .php). (Recommended learning: yii tutorial )

In the config folder, main.php, ##

return [
    'charset' => 'utf-8',
    'language' => 'zh-CN',
    'timeZone' => 'Asia/Shanghai',
    'components' => [
        'cache' => [
            'class' => 'yii\caching\FileCache'
        ],
        'formatter' => [
            'dateFormat' => 'yyyy-MM-dd',
            'timeFormat' => 'HH:mm:ss',
            'datetimeFormat' => 'yyyy-MM-dd HH:mm:ss'
        ]
    ]
];

The above is the detailed content of Where to set the time zone in yii2. For more information, please follow other related articles on the PHP Chinese website!

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