Home  >  Article  >  Backend Development  >  How to solve linux php date error problem

How to solve linux php date error problem

藏色散人
藏色散人Original
2021-10-19 09:59:412005browse

Solution to Linux php date error: 1. Determine whether the Linux system time is correct; 2. Check the time zone in php.ini; 3. Find ";date.timezone=" and add "Asia/ Shanghai" is enough.

How to solve linux php date error problem

The operating environment of this article: linux5.9.8 system, PHP7.1 version, DELL G3 computer

How to solve linux php date error Problem?

Linux error resolution related to PHP time function

Recently, I have written a lot of functions date() strtotime(), etc. to obtain time or timestamp in the program, but When the program was run on Linux, errors in these functions occurred. The specific reason was due to the time setting of Linux itself and the time zone problem of PHP.

First make sure the linux system time is correct:

Change the time zone to Shanghai, China

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Then check the time zone in php.ini

Find ;date.timezone=

Remove the semicolon, and then add Asia/Shanghai

Recommended learning: "PHP Video Tutorial

The above is the detailed content of How to solve linux php date error problem. 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