How to change the default time zone in php

王林
Release: 2023-03-09 12:34:02
Original
2520 people have browsed it

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 =
Copy after login

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
Copy after login

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!

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