Home >Backend Development >PHP Tutorial >3种方法修改PHP时区

3种方法修改PHP时区

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 14:24:20808browse

PHP5.2.4之前的版本无需设置时区。下面是修改PHP时区的三个办法。

1、修改PHP.ini这个文件

找到date.timezone这行,去掉前面的分号,改成:

date.timezone = Asia/Shanghai

2、修改 .htaccess文件

修改.htaccess文件有两种办法,下面的两条语句只要有一条即可

php_value date.timezone Asia/Shanghai

SetEnv TZ Asia/Shanghai

3、修改PHP代码

也是下面的两条语句只要其中的一句即可

date_default_timezone_set('Asia/Shanghai');

ini_set('date.timezone','Asia/Shanghai');

例如:

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
Previous article:xdebug的安装Next article:PHP程序开发的原则汇总