search
HomeBackend DevelopmentPHP ProblemHow to change the default time zone in php

How to change the default time zone in php

Apr 28, 2021 pm 01:57 PM
phpTime zone

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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

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.

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

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.