解決 PHP 5.3.0 + WordPress 造成 It is not safe to rely on the system’s timezone settings.
Author: Eric // Category: Free TeachingWarning: 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /Path_to_your/www/wp-includes/functions.php on line 35
Warning: date() [function.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. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /Path_to_your/www/wp-includes/functions.php on line 43
Warning: 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 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /Path_to_your/www/wp-includes/functions.php on line 35
Warning: date() [function.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. We selected 'Europe/Helsinki' for 'EEST/3.0/DST' instead in /Path_to_your/www/wp-includes/functions.php on line 43
00. 大多看到這問題發生在您用的是 PHP 5.3.0 或使用套裝軟體搭配的 PHP 版本是 5.3.0。
01. 下面為解決的方法, 則一使用即可, 依推薦使用的順序排序。
1. 修改 ./wp-config.php, 加上
date_default_timezone_set('Asia/Taipei');2. 修改 ./wp-includes/functions.php
a. 在第一個 function 前面加上
date_default_timezone_set('UTC+8');b. 在第一個 function 前面加上
date_default_timezone_set('Asia/Taipei');3. 修改 php.ini, 加上
date.timezone = "Asia/Taipei"
02. 上面的 Asia/Taipei 均可以替換成下面任一城市, 其它城市請到 PHP timezones 尋找
日本 : Asia/Tokyo
台北 : Asia/Taipei
重慶 : Asia/Chongqing
漢城 : Asia/Seoul
上海 : Asia/Shanghai
新加坡 : Asia/Singapore
澳門 : Asia/Macao 或 Asia/Macau
香港 : Asia/Hong_Kong 或 Asia/Chungking
03. 上面所提到的套裝軟體為 AppServ, PHPnow, XAMPP, WampServer, APMServ, EasyPHP。
Ref:
01. WordPress Support
02. PHP date_default_timezone_set
Tags: APMServ, Appserv, date_default_timezone_set, EasyPHP, PHP, php.ini, PHPnow, timezone, WampServer, WordPress, XAMPP
October 4th, 2009 at 6:40 AM
还没碰到过这个情况,先收藏了,以备不测
October 9th, 2009 at 7:21 PM
我通过第二条 修改 ./wp-includes/functions.php后,现实的不是这种错误了,而是Only variables should be passed by reference,不知道这又是哪里的问题?
October 9th, 2009 at 9:01 PM
請問一下, 您是加在如下面的位置嗎?
<?php
/**
* Main WordPress API
*
* @package WordPress
*/
/**
* ......
* ......
*/
date_default_timezone_set('UTC+8');
function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) {
.....
}
....
?>
如果答案是"Yes"的話, 那請把 +8 去掉看看
如果答案是"Yes"的話, 那其它的方法您有試過嗎?
October 9th, 2009 at 10:48 PM
我就是加在那里的,出现的那个错误,想用第一种方法,修改./wp-config.php,可是不知道那段代码加到哪里...
October 9th, 2009 at 11:07 PM
您可以加在 define ('WPLANG', ''); 的前面或後面
October 10th, 2009 at 3:31 PM
还是上面我说的那种错误,应该是服务器禁用了一些函数...我直接下载到电脑上吧...