为什么在php.ini中设置了date.timezone = PRC 后时区仍然出错

alreadydead 2010-07-08 09:37:27
根据网上的说明,将php.ini的date.timezone值设为PRC,但在页面中调用date()函数仍会提示我需要设置时区
It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.

php.ini中的设置应该没有问题,拼写什么的也都正确
...全文
5700 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
alreadydead 2010-08-12
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 hartyu 的回复:]
我也在为这个问题烦恼呢
[/Quote]
注意一下apache设置里面默认的php.ini文件的路径
我的是因为路径不对根本没有读取php.ini文件。
hartyu 2010-08-12
  • 打赏
  • 举报
回复
我也在为这个问题烦恼呢
alreadydead 2010-07-08
  • 打赏
  • 举报
回复
谢谢各位的解答,特别是CunningBoy,问题已解决。
  • 打赏
  • 举报
回复
我是直接写在全局common.php文件里面的啊
date_default_timezone_set('PRC');
CunningBoy 2010-07-08
  • 打赏
  • 举报
回复
就在date函数中,第一个参数可以设timezone的
date("O +0800", time());
alreadydead 2010-07-08
  • 打赏
  • 举报
回复
用phpinfo()查看了一下系统信息果然Default timezone 设置为了UTC

我还想请教一下 Default timezone 可不可以在哪里设置?
CunningBoy 2010-07-08
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 cunningboy 的回复:]

Unix / Liunx下用date命令查看
Windows下在控制面板中
[/Quote]
说错了,这个是第4个系统system的timezone查看方法

第二个TZ应该是phpinfo()列出的date部分的Default timezone
CunningBoy 2010-07-08
  • 打赏
  • 举报
回复
Unix / Liunx下用date命令查看
Windows下在控制面板中
alreadydead 2010-07-08
  • 打赏
  • 举报
回复
那请问要如何查看或者修改TZ的设置呢?
CunningBoy 2010-07-08
  • 打赏
  • 举报
回复
上面说的这是读取顺序,TZ的优先级在ini之前,你要检查TZ的设置
alreadydead 2010-07-08
  • 打赏
  • 举报
回复
Reading the value of the date.timezone ini option (if set)


我设置了为什么还不行?
CunningBoy 2010-07-08
  • 打赏
  • 举报
回复
In order of preference, this function returns the default timezone by:

Reading the timezone set using the date_default_timezone_set() function (if any)

Reading the TZ environment variable (if non empty)

Reading the value of the date.timezone ini option (if set)

Querying the host operating system (if supported and allowed by the OS)
alreadydead 2010-07-08
  • 打赏
  • 举报
回复
重启过,Asia/Shanghai也试过,都没有效果

但是在页面前加上date_default_timezone_set("PRC") 后可以正常显示。
床上等您 2010-07-08
  • 打赏
  • 举报
回复
配置后重启apache了没??

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧