CakePHP中的时区错误?

时间:2011-11-26 12:15:52

标签: cakephp

我在CakePHP中收到以下错误:

  

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

我也收到了通知:

  

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

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

任何提示?

2 个答案:

答案 0 :(得分:14)

您必须在date_default_timezone_set中取消注释app/config/core.php行,警告就会消失。

答案 1 :(得分:3)

/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');