【问题标题】:Warning (2): strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings警告(2):strtotime() [function.strtotime]:依赖系统的时区设置是不安全的
【发布时间】:2010-12-13 11:56:18
【问题描述】:
Warning (2): strtotime() [function.strtotime]: 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 'Asia/Calcutta' for '5.5/no DST' instead [CORE\cake\libs\cache.php, line 570]
Code | Context

$settings = array(
 "engine" => "File",
 "path" => "C:\xampp\htdocs\cakephp\app\tmp\cache\persistent\",
 "prefix" => "cake_core_",
 "lock" => false,
 "serialize" => true,
 "isWindows" => true,
 "duration" => "+10 seconds",
 "probability" => 100
)

strtotime - [internal], line ??
CacheEngine::init() - CORE\cake\libs\cache.php, line 570
FileEngine::init() - CORE\cake\libs\cache\file.php, line 81
Cache::_buildEngine() - CORE\cake\libs\cache.php, line 151
Cache::config() - CORE\cake\libs\cache.php, line 126
Configure::__loadBootstrap() - CORE\cake\libs\configure.php, line 421
Configure::getInstance() - CORE\cake\libs\configure.php, line 52
include - CORE\cake\bootstrap.php, line 38
[main] - APP\webroot\index.php, line 76


Notice: Trying to get property of non-object in C:\xampp\htdocs\cakephp\cake\libs\cache\file.php on line 248

Fatal error: Call to a member function cd() on a non-object in C:\xampp\htdocs\cakephp\cake\libs\cache\file.php on line 248

【问题讨论】:

  • ……是吗?你也想提出一个问题吗?
  • 幸运的是,我能够从其他无用的错误消息转储中得出问题,我可以理解为什么普通人可能会遇到麻烦 :-) 也许,鉴于 SO 是一个问答网站,你应该问一个问题。

标签: cakephp


【解决方案1】:

/app/config/core.php:

/**
 * If you are on PHP 5.3 uncomment this line and correct your server timezone
 * to fix the date & time related errors.
 */
    //date_default_timezone_set('UTC');

【讨论】:

  • 我用过。现在我收到错误:致命错误:在第 177 行的 /var/www/html/authbridge/lib/Cake/Model/Datasource/Database/Mysql.php 中找不到类“PDO”
  • 另外,在 Cakephp 2.x 下,您必须取消注释并编辑 //Configure::write('Config.timezone', 'Europe/Paris'); 行。
  • 非常感谢,这对我来说是个问题。
【解决方案2】:

这在此处和其他地方都有很好的记录。 Timezone and more problems with Cakephp 1.3 and PHP 5.3.2

成为一名熟练的开发人员的一部分是努力解决自己的问题。你就是这样学习的。当有这么多关于这个问题的报道时,你不太可能在这里找到同情的耳朵,因为每个人都知道你自己没有做出任何努力。

【讨论】:

  • 这哥们有点自负,OP来求救了。
【解决方案3】:

非常警告提到了有问题的功能,你搜索过吗? Here's what it says in the docs:

如果时区无效,每次调用日期/时间函数都会生成 E_NOTICE,如果使用系统设置或 TZ 环境变量,则会生成 E_STRICT 或 E_WARNING 消息。另见 date_default_timezone_set()

换句话说,您应该为您的服务器显式设置 TZ,either in php.ini,或使用 date_default_timezone_set()

【讨论】:

    【解决方案4】:

    要删除此 E_STRICT 或 E_WARNING 消息,请取消注释 app/config/core.php 中带有 date_default_timezone_set 的行

    【讨论】:

      猜你喜欢
      • 2017-12-07
      • 2016-07-22
      • 2019-06-22
      • 1970-01-01
      • 2011-08-07
      • 2012-07-12
      • 2011-03-20
      • 2012-09-14
      • 2011-08-27
      相关资源
      最近更新 更多