CodeIgniter TimeZone time zone problem and PHP time zone setting
I used the CodeIgniter framework to build the site, use Date (' y-m-d h:i:s ') to get the time and deposit it in the database, but today I found that the time to deposit was much better than my local difference.
Because the time zone is not the same as China time, there are two ways to solve the problem:
(1) Modify PHP.ini
[Date]; Defines the default timezone used by the date functions; Http://php.net/date.timezonedate.timezone = PRC
After modification, restart Apache.
(2) Use Date_default_timezone_set ("Asia/shanghai") before using date ()
China region has the following parameters can be set, the specific classification method to be examined.
{"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 the CodeIgniter, after using date, found that the time is still much worse, so, CodeIgniter must have set the time zone configuration.
View discovery: File application/config/my_config.php has the following settings:
!--? php date_default_timezone_set (' america/los_angeles ');
Just change to Date_default_timezone_set ("Asia/shanghai").