Home  >  Article  >  Backend Development  >  php.ini时区有关问题

php.ini时区有关问题

WBOY
WBOYOriginal
2016-06-13 13:15:181294browse

php.ini时区问题
php.ini设了
date.timezone = Asia/Chongqing
但还是差8个钟。


phpinfo有看到
date.timezone Asia/Chongqing Asia/Chongqing
Default timezone Etc/GMT+0



之前都是用php设,date_default_timezone_set('Etc/GMT-8');
没有问题,但这样要一个站一个站去改,不想这么搞了

想问下php.ini应该怎么改才正确,谢谢各位。




------解决方案--------------------
我给你查了一下,不知这贴子你看了没
http://blog.csdn.net/hzhuoquan/article/details/4957836

一般都是在网站的config文件里添加一个全局的时区宏变量

------解决方案--------------------
一直都是在php中设置的路过....
------解决方案--------------------
date_default_timezone_set('Asia/shanghai');
那你只能这样了
------解决方案--------------------
先确认一下,你的php版本是?
------解决方案--------------------
date.timezone = Asia/Shanghai;上海 不一样使用北京时间吗
date.timezone = Asia/Chongqing;重庆 不一样使用北京时间吗
date.timezone = PRC;中华人民共和国

------解决方案--------------------
那就试试 date.timezone = Etc/GMT-8
可能相关常量没有被编译进去
------解决方案--------------------
你那里怎么有Default
我的是PHP Version 5.3.1
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone = "UTC"
date.timezone ="Etc/GMT-8"

我设为这样的
重启apache后
phpinfo显示为

date
date/time support enabled
"Olson" Timezone Database Version 2009.18
Timezone Database internal
Default timezone Etc/GMT-8 

echo "

";<br>print_r(getdate());<br>echo "
";
输出为
Array
(
[seconds] => 38
[minutes] => 53
[hours] => 13
[mday] => 3
[wday] => 5
[mon] => 8
[year] => 2012
[yday] => 215
[weekday] => Friday
[month] => August
[0] => 1343973218
)
你不是改错文件,就是改多了,不是改多了就是apache未重启,不是未重启就是人品太差了



------解决方案--------------------
缓存?还有谁也插手这事?nginx比apache更忙可能
海量搜捕这俩关健字 "Default timezone" , "Etc/GMT+0"
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