CodeIgniter TimeZone time Zone related issues and PHP time zone settings

Source: Internet
Author: User
Tags codeigniter
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").

 
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.