Codeigniter timezone and PHP time zone settings

Source: Internet
Author: User
Tags codeigniter

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:

 
<? PHP date_default_timezone_set ('America/los_angeles ');

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.