PHP日期函数在Ver 5.3.0中无法正常运行

时间:2011-07-23 04:37:55

标签: php date

我正在使用日期函数echo date ('Y');,这会导致以下错误消息。

警告:date()[function.date]:依赖系统的时区设置是不安全的。

这与我的php.ini页面有什么关系吗?我需要在php.ini中进行哪些更改才能使此代码正常工作?

2 个答案:

答案 0 :(得分:2)

要使该警告消失,您需要使用此功能设置您的时区:
http://php.net/manual/en/function.date-default-timezone-set.php

或在你的php.ini中设置:
http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone

<小时/> 更新
从下面的评论,这里有效的时区:
http://www.php.net/manual/en/timezones.php

答案 1 :(得分:1)

将时区设置为您想要的时区

// example
date_default_timezone_set('America/Los_Angeles');

请参阅valid timezones

列表