Home > PHP Framework > YII > body text

Where to set the time zone in yii2

(*-*)浩
Release: 2019-12-30 11:40:50
Original
3558 people have browsed it

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'
        ]
    ]
];
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!