PHP Mktime错误

Cli*_*ote 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
Run Code Online (Sandbox Code Playgroud)

这是有问题的代码:

$stamp=mktime(0,0,0,$month,$day,$year);
Run Code Online (Sandbox Code Playgroud)

这是什么问题?如何快速消除这些错误?我mktime在很多地方使用这种格式,并在每个地方抛出错误.

Fra*_*nes 7

由于错误的说法,你要么需要使用指定时区date_default_timezone_set('Antarctica/Macquarie');ini_set('date.timezone', 'Antarctica/Macquarie');在你的代码或定义date.timezonephp.ini.

  • @PaulPRO - 时间戳是处理日期时的一个重要概念,特别是因为时间戳是基于Unix Epoch(GMT).除非绝对必要,否则应该**永远不要**压制错误消息. (2认同)