Home > Backend Development > PHP Problem > How to set time zone in php date

How to set time zone in php date

coldplay.xixi
Release: 2023-03-05 18:32:01
Original
3258 people have browsed it

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.

How to set time zone in php date

[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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template