Home >Backend Development >PHP Tutorial >PHP 设置时区的问题

PHP 设置时区的问题

WBOY
WBOYOriginal
2016-06-06 20:40:551340browse

怎么破?
Notice: date_default_timezone_set(): Timezone ID 'Asia/shanghai' is invalid

回复内容:

怎么破?
Notice: date_default_timezone_set(): Timezone ID 'Asia/shanghai' is invalid

Asia/shanghai 大写Shanghai

date_default_timezone_set('Asia/Shanghai'); //时区配置

设置为PRC就可以的。


不好意思,没仔细看提问就回答了。
你应该先确认你是否有这些时区。
使用linux命令,如果是CentOS可以这样重看时区:

<code>[root@localhost ~]# timedatectl list-timezones | grep Shanghai
Asia/Shanghai
[root@localhost ~]# timedatectl list-timezones | grep beijing
</code>

没有北京,那设置为Asia/Shanghai。

在php.ini文件你设置date.timezone = PRC,重启apache或者nginx 即可解决,已经测试过,谢谢采纳

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