'UTC'"; 2. Modify it to "'timezone' => 'Asia/Shanghai'" is enough."/> 'UTC'"; 2. Modify it to "'timezone' => 'Asia/Shanghai'" is enough.">

Home >PHP Framework >Laravel >How to set China time zone in laravel

How to set China time zone in laravel

青灯夜游
青灯夜游Original
2021-09-17 15:18:195544browse

How to set the Chinese time zone: 1. Open the "app.php" file in the "app/config/" path under the laravel framework directory and find "'timezone' => 'UTC'"; 2. Change Just modify it to "'timezone' => 'Asia/Shanghai'".

How to set China time zone in laravel

The operating environment of this tutorial: Windows 7 system, Laravel 6 version, Dell G3 computer.

Recently I wrote a small program using laravel as the backend. I found that created_at was 8 hours less than Beijing time. .

I checked the settings of PHP and found that there was no problem. Then I checked laravel and found that the time zone setting was wrong. Just modify it.

How to set the Chinese time zone in laravel:

1. Open the app/config/app.php file in the laravel framework directory

and you will find the following line:

'timezone' => 'UTC'

so, change it to

'timezone' => 'Asia/Shanghai',

Save the changes and it will be ok, the time will be normal.

Related recommendations: The latest five Laravel video tutorials

The above is the detailed content of How to set China time zone in laravel. 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