【问题标题】:PHP date.timezone no valuePHP date.timezone 没有值
【发布时间】:2014-07-09 04:13:49
【问题描述】:

我只是在 windows OS x64 上创建新服务器。

httpd-2.4.9-win64-VC11
php-5.5.14-Win32-VC11-x64
MySql Server

我进入php.ini取消注释并添加:

date.timezone = "Asia/Kuala_Lumpur"

我在phpinfo.php 中创建并查看,并在本地和主值中找到了我的date.timezoneno value

如下

启用日期/时间支持“Olson”时区数据库版本 2014.3 时区 数据库内部 默认时区 UTC

指令本地值主值 date.default_latitude 31.7667 31.7667 date.default_longitude 35.2333 35.2333 date.sunrise_zenith 90.583333 90.583333 date.sunset_zenith 90.583333 90.583333 date.timezone no value no value

在同一页面(phpinfo.php)上也出现error message,如下:

Warning: phpinfo(): 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. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in J:\WebDocs\gad\phpinfo.php on line 2

Warning: phpinfo(): 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. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in J:\WebDocs\gad\phpinfo.php on line 2

这是我目前的php.ini

http://codepad.org/u2xHBP8a

这与 php.ini 模块有关吗?以及解决此问题的最佳方法是什么。

【问题讨论】:

  • 你重启了apache吗?你编辑了正确的 php.ini 吗?
  • @Lashane 是的,我重新启动 apache 并发生同样的情况。
  • 确保您正在编辑正确的 php.ini。有些系统有一个单独的 CLI 和 Apache。在 web 文件中运行 phpinfo(),顶部将给出解析后的 ini 文件的路径。
  • 请确保您编辑的 php.ini 是 apache 使用的那个。在您的 phpinfo() 中,标题中有一行关于“加载的 PHP 配置”或类似的内容,其中包含 php.ini 的路径。
  • 我找到了解决方案,因为睡眠不足我添加了 PHPIniDir "H:/PHP" 这是错误的,应该是 PHPIniDir "J:/PHP"

标签: php timezone


【解决方案1】:

这是我今天早上找到的快速解决方案

httpd.confPHPIniDir

"H:/PHP"

应该这样

"J:/PHP"

【讨论】:

  • 所以,您加载了错误的 php.ini 文件...因为您在 httpd.conf 中放置了错误的 phpinidir。如果您在配置方面遇到问题,请务必先检查它 - 打开 phpinfo 并查看加载了哪个文件。
  • @Toly 指出,大师。 +2。
【解决方案2】:

美国/中部不是 PHP 的有效时区。

有效的美国时区在这里:http://www.php.net/manual/en/timezones.america.php

对于中部时间,请改用 America/Chicago。

【讨论】:

  • 我之前尝试过,这不是当前的解决方案。
  • 是的,它是有效的,只是不推荐。 Reference here.
猜你喜欢
  • 1970-01-01
  • 2016-08-26
  • 1970-01-01
  • 1970-01-01
  • 2012-10-22
  • 1970-01-01
  • 2016-06-29
  • 2012-07-04
  • 1970-01-01
相关资源
最近更新 更多