我在PHP代码中有这一行来生成基于日期,成员ID和注释的guid:
$md5c = md5($member_id.$comment.$topic_id.$plan_id.date("Y-m-d") );
最近它开始发出这样的警告信息:
Warning: 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 the timezone 'UTC' for now, but please set date.timezone to select your timezone.
有人知道如何更改该代码以便不生成此警告吗?
谢谢!
答案 0 :(得分:1)
您可能需要将时区放在php.ini文件的配置行中。你应该在php.ini文件中有一个这样的块:
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = America/New_York
如果没有,请添加它(由您的时区替换)。配置完成后,请确保重新启动httpd(service httpd restart)。
这是list of supported timezones。 引用为here。