Home >Backend Development >PHP Problem >How to change the default time zone in php

How to change the default time zone in php

王林
王林Original
2021-04-28 13:57:272560browse

How to modify the default time zone in php: first open the php configuration file and search for date.timezone; then cancel the comment before date.timezone; finally fill in the corresponding time zone identifier and restart the server.

How to change the default time zone in php

The operating environment of this article: windows10 system, php 5.0, thinkpad t480 computer.

First we need to make the following settings in the configuration file:

The PHP configuration file is the php.ini file in the PHP installation directory. Find and open it. Then search for date.timezone in the file, we will see a piece of information as shown below:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =

where; date.timezone = the previous; has the same function as // in PHP, both The meaning of the comment, here we need to remove this; and fill in the corresponding time zone identifier after = in this sentence, as shown below:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Shangha

There are many time zone identifiers, and some commonly used time zones are listed below Identifiers and their meanings:

  • Asia/Shanghai - Shanghai

  • Asia/Chongqing - Chongqing

  • Asia/Urumqi —— Urumqi

  • Asia/Hong_Kong —— Hong Kong

  • Asia/Macao ——Macao

  • Asia/Taipei - Taipei

  • Asia/Singapore - Singapore

  • PRC - China Time Zone

Tip: If you are in China, we can set the time zone to "Asia/Shanghai or PRC". After the setting is successful, remember to restart the server!

Free learning video sharing: php tutorial

The above is the detailed content of How to change the default time zone in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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

Related articles

See more