Home  >  Article  >  php教程  >  详细解读PHP时区修改正确方法

详细解读PHP时区修改正确方法

WBOY
WBOYOriginal
2016-06-13 11:10:341453browse

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');

例如:

<ol class="dp-xml">
<li class="alt"><span><span class="tag"><span> ?php   </span></span></span></li>
<li><span>date_default_timezone<br>_set('Asia/Shanghai');   </span></li>
<li class="alt">
<span class="tag">?></span><span> </span>
</li>
</ol>


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