如何修复与时区相关的PHP错误(function.strtotime和function.date) [英] How to fix PHP errors related to timezone (function.strtotime and function.date)

查看:153
本文介绍了如何修复与时区相关的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.

这篇关于如何修复与时区相关的PHP错误(function.strtotime和function.date)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆