Home  >  Article  >  Backend Development  >  How to set time zone in php ci

How to set time zone in php ci

藏色散人
藏色散人Original
2021-05-12 09:42:461335browse

php ci method to set the time zone: first find and open the "conifg/config.php" file; then add the code "date_default_timezone_set('Asia/ShangHai');" in the file.

How to set time zone in php ci

The operating environment of this article: windows7 system, CodeIgniter version 4.0, DELL G3 computer

Because the default time zone of CI is not China, the system time is obtained time, which is about 8 hours less than the normal time, so we need to set the time zone ourselves. Setting the time zone for the CI framework is very simple, just add the following code at the end of the "conifg/config.php" file:

/* 设置系统时区 */
date_default_timezone_set(‘Asia/ShangHai’);
$config[‘time_zone’] = date_default_timezone_get();

Recommended learning: "PHP Video Tutorial"

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