Set the current output time in the local time zone of php: & lt ;? Php $ timedate (Y-m-dH: I: s); echo $ time; hour? How is it 2009-02-2606: 52: 58. The time of the local machine (Shanghai) is clearly: 2009-02-2614: 52: 58. I entered the next 8 hours in advance. :) You have already guessed that the UTC + 8 zone is a time zone problem, how does php know the local time zone settings in php?
Output Current time:
Why? 06:52:58. The local machine (Shanghai) time is clearly: 14:52:58
I entered the next 8 hours in advance. :) You have already guessed that the UTC + 8 zone is a time zone problem. how does php know the time zone? Modify the settings in php. ini:
[Date]; Defines the default timezone used by the date functionsdate.timezone = Asia/Shanghai
Restart the server and run the code again. The time output is consistent.
In php5, the default value of php. ini is GMT, and that of Beijing is + 8 time zone,
It is not recommended to modify the time zone settings in php. ini by using the php script. if you have a server with full management rights, you can also modify the default time zone settings in php. ini. If you do not have the permission to change php. ini,
You can use the ini_set () and date_default_timezone_set functions to set
Use echo date_default_timezone_get (); to view the settings.