search
HomeBackend DevelopmentPHP ProblemHow to set time zone in php configuration file

How to set time zone in php configuration file

Jul 08, 2021 pm 06:36 PM
phpSet time zoneConfiguration file

How to set the time zone in the php configuration file: First find and open the configuration file "php.ini"; then search for the "date.timezone" item in the file and change the ";" in ";date.timezone=" "Remove, fill in the corresponding time zone identifier after "="; finally save the file and restart the server.

How to set time zone in php configuration file

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

php configuration file settings Time zone method

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 in front of it ; has the same function as // in PHP. They both mean comments. Here we need to remove this ; and add =## in this sentence. #Fill in the corresponding time zone identifier later, 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, which can be viewed by visiting "https://www.php.net/manual/zh/timezones.php" , the following lists some commonly used time zone 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

Tips: If you are in China, we can set the time zone to "

Asia/Shanghai or PRC" , remember to restart the server after successful setting!

[Example] Let’s use a piece of code to verify whether our settings are effective.

<?php
    echo date(&#39;Y-m-d H:i:s&#39;,time());
?>

The running result is as follows:

2021-07-08 18:33:22

If the running result is equal to the local time of our computer, it means that our setting is successful.

Recommended learning: "

PHP Video Tutorial"

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor