如何修复与时区相关的PHP错误(function.strtotime和function.date)

问题描述:

升级到新服务器,我遇到了两个重复的错误:

Upgrading to a new server, I two repeated errors:

警告:strtotime()[function.strtotime]:依靠它并不安全 系统的时区设置.您需要使用 date.timezone设置或date_default_timezone_set()函数.在 如果您使用了这些方法中的任何一种,但仍会得到此方法 警告,您很可能拼错了时区标识符.我们 在...中选择了美国/纽约/美国"作为"EST/-5.0/无夏令时".

Warning: strtotime() [function.strtotime]: 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 'America/New_York' for 'EST/-5.0/no DST' instead in...

警告:date()[function.date]:依赖于 系统的时区设置.您需要使用 date.timezone设置或date_default_timezone_set()函数.在 如果您使用了这些方法中的任何一种,但仍然会得到 警告,您很可能拼错了时区标识符.我们 在

Warning: date() [function.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 'America/New_York' for 'EST/-5.0/no DST' instead in

我该如何解决这些问题?

How do I go about fixing these?

有问题的代码是这样的:

Code in question is this:

'date' => date("Y-M-d",strtotime($Array['_dateCreated'])),

我尝试将其放在所有页面顶部的包含内容中:

I've tried putting this in an include at the top of all my pages:

<?php
date_default_timezone_set('America/New_York');
?>

预先感谢您的帮助.

date.timezone可以全局解决此问题.

date.timezone in php.ini can fix this globally.