PHP Warning: strtotime() error solution_PHP tutorial

WBOY
Release: 2016-07-13 10:42:47
Original
1346 people have browsed it

The strtotime() function is a php date function. This problem occurs because the date.timezone in our php.ini is not set properly. It can be solved by configuring the time zone.


Starting from php5.1.0, the date.timezone option has been added to php.ini, which is turned off by default. The displayed time is all Greenwich Mean Time, which is exactly 8 hours different from Beijing time.

The solution is:

Modify the php.ini file, search for ;date.timezone = , remove the semicolon in front and add the time zone after "=".

For example:

Asia/Chongqing (Chongqing),
Asia/Shanghai (Shanghai),
Asia/Urumqi (Urumqi),
Asia/Macao (Macau),
Asia/Hong_Kong (Hong Kong),
Asia/Taipei (Taipei),
PRC China

as

The code is as follows
 代码如下 复制代码

date.timezone = PRC

Copy code

 代码如下 复制代码

date_default_timezone_set('Asia/Chongqing');
echo date('Y-m-d H:i:s');
?>

date.timezone = PRC

You can also add

at the front of the program page in php
The code is as follows

Copy code

date_default_timezone_set('Asia/Chongqing');

echo date('Y-m-d H:i:s');

?>

Related recommended reading

Multiple solutions to the time difference of 8 hours in phphttp://www.bKjia.c0m/phper/31/42398.htm Solution to php date time difference of 8 hours http://www.bKjia.c0m/phper/31/37224.htm php gets the server time (solve the 8-hour gap problem) http://www.bKjia.c0m/phper/31/34041.htm
http://www.bkjia.com/PHPjc/633215.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/633215.htmlTechArticlestrtotime() function is a php date function. This problem occurs because of the date.timezone in our php.ini It's not set up properly, just configure the time zone to solve it. Starting from php5.1.0, php.ini is rigged...
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