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

How to set system time in php

藏色散人
Release: 2023-03-05 12:40:01
Original
4140 people have browsed it

How to set the system time in php: first find and open the "php.ini" file; then find the ";date.timezone=" option under "date"; then modify this item to "date.timezone" =Asia/hong_kong”; Finally, restart the server.

How to set system time in php

Recommended: "PHP Video Tutorial"

How to set the current time of the PHP system

Since PHP5.0 has rewritten the date() function, the current date and time function is 8 hours less than the system time.

In the PHP language, the default setting is It is standard Greenwich Time (that is, the zero time zone is used), so to obtain the current local time, you must change the time zone setting in the PHP language. The method is as follows.

In the php.ini file, find [ ";date.timezone=" option under date], change this item to "date.timezone=Asia/hong_kong", and then restart the Apache server.

After the setting is completed, the current time of the output system will be There will be no jet lag problem.

The above is the detailed content of How to set system time in php. 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