2011-07-17 37 views
3

我突然变得对我做了一个网站,已工作的罚款,到目前为止以下错误:PHP Mktime错误

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,并在每个地方抛出一个错误。

回答

7

如错误所述,您需要在代码中使用date_default_timezone_set('Antarctica/Macquarie');ini_set('date.timezone', 'Antarctica/Macquarie');指定时区,或者在php.ini中定义date.timezone

+0

能否请您提供我需要在php.ini文件中使用的代码? –

+0

@Click Upvote - 'date.timezone =“Antarctica/Macquarie”'。 –

+1

我不建议这样做,特别是如果这将在生产环境中。但是,如果这只是你正在做的乐趣或东西,你可以压制像这样的警告: '$ stamp = @mktime(0,0,0,$ month,$ day,$ year);' 它是这并不是一件好事,所以你应该修正你的问题。所以你可能应该修好你的php.ini – Paulpro