Solve the problem of 8 hours difference in PHP

Source: Internet
Author: User
During project development, we often encounter a difference of 8 hours between the obtained time and the actual time, because our time zone range is different from that of the PHP developer, the default value is not UTC + 8. There are two general solutions: 1. open the PHP configuration file php. I... SyntaxHighlighter. all ();

 

During project development, we often encounter a difference of 8 hours between the obtained time and the actual time, because our time zone range is different from that of the PHP developer, the default value is not UTC + 8. There are two solutions:

 

1. open the PHP configuration file. ini file, search for the date in the file. timezone: remove the annotator ";" from the front and add the "RPC" character at the end of the row. if the date cannot be found in the file. timezone, you can manually add it at any location. the modified date. timezone configuration:

 

Date. timezone = "RPC" 2. Sometimes developers cannot obtain the permission to operate the php. ini file. this method is required. Generally, if a project has a configuration file or an entry file, you can use date_default_timezone_set () to modify the time zone. For example:

 

Date_default_timezone_set ("Asia/Chongqing"); available values in mainland China: Asia/Chongqing, Asia/Shanghai, Asia/Urumqi (in the order of Chongqing, Shanghai, and Urumqi ), hong Kong and Taiwan regions are available: Asia/Macao, Asia/Hong_Kong, Asia/Taipei (in the order of Macao, Hong Kong, and Taipei ).

 

This article is from the "FrancisRan" blog

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.