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