When setting up a system with PHP on Linux, the application reminded me: “There is no date.timezone setting in the PHP configuration, so the system will default the time zone to UTC. But we recommend that you set this time zone yourself.”
After investigation, it turns out that since PHP 5, the time zone (data.timezone) is no longer set by default, causing programs to use UTC (Coordinated Universal Time) as the standard, which is GMT+0.
As a result, for those of us in the East Asian region (the Republic of China uses the Taipei time zone on the island of Taiwan as the standard), when running applications that use date-related functions, everything is 8 hours off.
How to Modify the PHP date.Timezone?
Through command instructions, or a panel control interface, find the corresponding PHP configuration table. Generally speaking, it is mainly the “php.ini” file, but it may differ slightly depending on how the operating system is used.
The following setting is the [date] field of the original PHP data. You can directly search for the timezone keyword to find it quickly:
[Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ;date.timezone =
Next, change “;date.timezone =” to the correct time zone “date.timezone = “Asia/Taipei"", then restart the Apache server to complete the setting.
The Second Method to Set the PHP Timezone
In addition, if you are using shared hosting, such as Bluehost. The system permissions may not allow you to modify the underlying PHP.INI. In this case, you can enter the following instruction in the program, which can also modify the correct time zone:
date_default_timezone_set(“Asia/Taipei”)
The only thing to note is that this method only applies to a specific application, which means that if you have two independent programs running, you need to set them separately!
Support Independent Perspectives & In-Depth Insights
Every thoughtful analysis and candid critique comes from our dedication to truth and quality. We choose not to follow sensational algorithms or clickbait headlines.
Sustaining independent research requires reader support. Make a one-time or monthly contribution, securely processed by Google.
Payments secured by Google · Manage or cancel anytime in your Google Account




Comments