我有一个登录脚本,用于检查某个时间段是否已过。意识到我有一个时间戳,我从我的数据库中使用 strtotime 获取时间戳,这样我就可以轻松地向这个时间/字符串添加一个秒值来检查这个特定的日期/时间是否已经过去。
昨天我更新到 php 5.3。现在我收到一条错误消息:
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 'Europe/Berlin' for 'CEST/2.0/DST' instead in /xxx/xxx/xxxx/xxx/login.php on line xx
在这条线上实现:
$DOA = strtotime($row->DOA);
问题是,我该如何使用:
date.timezone = "Europe/Berlin"
date.default_latitude = 52.5194
date.default_longitude = 13.4067
转换时间戳
$row->DOA
我必须得到一个字符串。或者是这样的:
date.timezone = "Europe/Berlin"
date.default_latitude = 52.5194
date.default_longitude = 13.4067
只是我应该添加的信息,因为据说
We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead...
被使用。
如果有人可以给我建议来解决这个问题,我将不胜感激。
最佳答案
我认为只是未设置 PHP 时区。所以您可以在 php.ini 中执行此操作或在您的 php 文件中声明它。
date_default_timezone_set('Europe/Berlin');
$DOA = strtotime($row->DOA);
看看这是否消除了您的错误。
关于php - 如何获取时区信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10224768/