A PHP Error was encountered
Severity: Warning
Message: 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/Berlin' for 'CET/1.0/no DST' instead
我从我的php页面收到此错误。我使用codeigniter作为框架。这是我用来创建日期的代码:
$datestring = "%d/%m/%Y - %h:%i %a";
$time = time();
$data['curr_time'] = mdate($datestring, $time);
错误在哪里?
答案 0 :(得分:4)
我猜你有php 5.3。 无论如何,解决方案是通过在使用任何时间/日期函数之前向您的php文件添加下一个代码来定义php的时区:
date_default_timezone_set('UTC');
或更好的解决方案,编辑你的php.ini文件并添加:
date.timezone =“America / Anchorage”
America/Anchorage
是时区,请使用列表中与您相关的时区:
答案 1 :(得分:4)
在index.php文件中使用以下代码
if( !ini_get('date.timezone') )
{
date_default_timezone_set('America/New_York');
}