CodeigniterTimeZone and PHP time zone settings I use the Codeigniter framework to build a website, use date ('Y-m-dh: I: s') to get the time and store it in the database, but today, I found that the stored time is much different from my local time. Because the time zone is incorrect, the time is inconsistent with the China time. There are two solutions: (1) modify the p Codeigniter TimeZone and set the PHP time zone.
I use the Codeigniter framework to build a website, and use date ('Y-m-d h: I: s') to get the time and store it in the database. but today I found that, the storage time has a lot of time difference with my local storage.
Because the time zone is incorrect and the time in China is inconsistent, there are two solutions:
(1) modify php. ini
[Date]; Defines the default timezone used by the date functions; http://php.net/date.timezonedate.timezone = PRC
Restart apache after modification.
(2) use date_default_timezone_set ("Asia/Shanghai") before using date ")
The following parameters can be set in China. The specific classification method is to be investigated.
{ "cst", 0, 28800, "Asia/Chongqing" },{ "cst", 0, 28800, "Asia/Chungking" },{ "cst", 0, 28800, "Asia/Harbin" },{ "cst", 0, 28800, "Asia/Kashgar" },{ "cst", 0, 28800, "Asia/Macao" },{ "cst", 0, 28800, "Asia/Macau" },{ "cst", 0, 28800, "Asia/Shanghai" },{ "cst", 0, 28800, "Asia/Taipei" },{ "cst", 0, 28800, "Asia/Urumqi" },{ "cst", 0, 28800, "PRC" },{ "cst", 0, 28800, "ROC" },
However, in codeigniter, after date is used, it is found that the time difference is much better. Therefore, codeigniter must have the time zone configuration.
The following settings are available in the application/config/MY_config.php file:
Change to date_default_timezone_set ("Asia/Shanghai.