【问题标题】:Timezone error in CakePHP?CakePHP 中的时区错误?
【发布时间】:2011-11-26 12:15:51
【问题描述】:

我在 CakePHP 中收到以下错误:

警告(2):strtotime() [http://php.net/function.strtotime]:依赖系统的时区设置是不安全的。您需要使用 date.timezone 设置或 date_default_timezone_set() 函数。如果您使用了这些方法中的任何一种,但仍然收到此警告,您很可能拼错了时区标识符。我们为 'CEST/2.0/DST' 选择了 'Europe/Berlin' [ROOT/cakephp/cake/libs/cache.php,第 570 行]

我也收到了通知:

试图在第 248 行获取 /htdocs/cakephp/cake/libs/cache/file.php 中非对象的属性 致命错误:在 /htdocs/cakephp 中的非对象上调用成员函数 cd() /cake/libs/cache/file.php 在第 248 行

我已将date_default_timezone_set("America/Anchorage"); 行添加到[cake base directory]/libs/cache.php 的顶部以尝试解决问题。 但错误仍然存​​在。

有什么提示吗?

【问题讨论】:

    标签: 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');
    

    【讨论】:

      【解决方案2】:

      您必须在app/config/core.php 中取消注释带有date_default_timezone_set 的行,警告应该会消失。

      【讨论】:

      • 这是解决方案,不要在别处浪费时间:D
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多