How to set timezone in php: 1. Set "date.timezone="Asia/Shanghai"" in "php.ini"; 2. Add "date_default_timezone_set("PRC");" to the page; 3. , add setting time zone in the header of the page.
Recommended: "PHP Video Tutorial"
Three types of time zone settings in PHP Method
Method 1:
(The best method) Add the date.timezone item found in php.ini, set date.timezone = "Asia/Shanghai", and restart the environment It’s ok.
Method 2:
When you need to use these time functions, add date_default_timezone_set("PRC");
Method 3:
Add the setting time zone ini_set('date.timezone','Asia/Shanghai');
to the header of the page. In summary, method one and method three generally require server permissions to be more effective. , and method 2 technicians can control the current page, which is also a commonly used method by programmers.
The above is the detailed content of How to set timezone in php. For more information, please follow other related articles on the PHP Chinese website!