Home >Backend Development >PHP Problem >How to set time zone in php date
php date How to set the time zone: First, add the [date.timezone] item in [php.ini]; then set [date.timezone = "Asia/Shanghai"]; and finally restart the environment.
[Related learning recommendations: php programming (video)]
php date Method to set time zone:
Method 1:
(the best method) in php.ini Add the date.timezone item found, set date.timezone = "Asia/Shanghai", and restart the environment and it will be 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 1 and Method 3 generally require server permissions to be more effective, while Method 2 technicians You can control the current page, which is also a commonly used method among programmers.
If you want to know more about programming learning, please pay attention to the php training column!
The above is the detailed content of How to set time zone in php date. For more information, please follow other related articles on the PHP Chinese website!