我突然在我已经完成的网站上收到以下错误,到目前为止工作正常:
A PHP Error was encountered
Severity: Warning
Message: mktime() [function.mktime]: 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 'Antarctica/Macquarie' for 'EST/10.0/no DST' instead
这是有问题的代码:
$stamp=mktime(0,0,0,$month,$day,$year);
这里有什么问题?如何快速消除这些错误?我在很多地方使用mktime
格式,并且在每个地方都会出错。
答案 0 :(得分:7)
如错误所示,您需要在代码中使用date_default_timezone_set('Antarctica/Macquarie');
或ini_set('date.timezone', 'Antarctica/Macquarie');
指定时区,或在date.timezone
中定义php.ini
。
答案 1 :(得分:0)
您能否确认$month
,$day
和$year
是INT - 甚至不是NULL?