Home  >  Article  >  Backend Development  >  Solving the 8-hour time difference problem in PHP_PHP Tutorial

Solving the 8-hour time difference problem in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:46:381077browse

During the project development process, we often encounter situations where the obtained time is 8 hours different from the actual time. This is because our time zone is different from that of PHP developers, and it is not the East Eighth District by default. There are two general solutions:

1. Open the PHP configuration file php.ini file, search for date.timezone in the file, remove the comment character ";" in front, and then add the character "RPC" at the end of the line. If date cannot be found in the file .timezone, you can add it manually at any location. The modified date.timezone configuration is:

date.timezone = "RPC" 2. Sometimes developers do not have access to the php.ini file, so this method is needed. Generally, a project has a configuration file or entry file, and you can use the date_default_timezone_set () method in these files to modify the time zone. For example:

date_default_timezone_set ("Asia/Chongqing"); Available values ​​in mainland China are: Asia/Chongqing, Asia/Shanghai, Asia/Urumqi (in order Chongqing, Shanghai, Urumqi), available values ​​in Hong Kong and Taiwan: Asia/Macao, Asia/Hong_Kong, Asia/Taipei (Macau, Hong Kong, Taipei in order).

This article is from the “FrancisRan” blog

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478564.htmlTechArticleDuring the project development process, we often encounter situations where the obtained time differs from the actual time by 8 hours. This It's because our time zone is different from that of PHP developers...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn