This article introduces the solution to the time zone problem of the date function in PHP, which causes the output time to be incorrect. Friends in need can refer to it.
Problem: echo date('o-m-j H:i'); The output result is 8 hours different from the local time. Cause: The time zone is not set correctly. Solution: Method 1. Join date_default_timezone_set('Asia/Shanghai');Method 2, modify php.ini [Date] ; Defines the default timezone used by the date functions date.timezone = PRC Note: PRC stands for Sinochem People’s Republic of ChinaTest it yourself, you will know after a try, and you can easily solve the date function time zone problem. |