Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何获取时区信息_Php_Mysql_Datetime_Localization_Timezone - Fatal编程技术网

Php 如何获取时区信息

Php 如何获取时区信息,php,mysql,datetime,localization,timezone,Php,Mysql,Datetime,Localization,Timezone,我有一个登录脚本,我检查某个时间段是否已过。认识到我有一个时间戳,我用strotime从我的数据库中获取它,这样我就可以很容易地在这个时间/字符串中添加一个秒值来检查这个特定的日期/时间是否已经过去 昨天我更新到了PHP5.3。现在我收到一条错误消息: Warning: strtotime() [function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to

我有一个登录脚本,我检查某个时间段是否已过。认识到我有一个时间戳,我用strotime从我的数据库中获取它,这样我就可以很容易地在这个时间/字符串中添加一个秒值来检查这个特定的日期/时间是否已经过去

昨天我更新到了PHP5.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);
查看这是否消除了错误。

您可以使用以下代码:

$timestamp = '1334826954';
$dateTime = new DateTime();
$dateTime->setTimezone(new DateTimeZone('Europe/Berlin'));
$dateTime->setTimestamp($timestamp);
echo $dateTime->format('Y-m-d H:i:s');
输出

2012-04-19 11:15:54

问题标题与问题本身不匹配,甚至问题本身也很混乱。是否要获取客户端的时区?你想知道你的时区吗?您需要帮助来修复警告吗?你想在时区之间转换吗?可能重复的是“转换时间戳”,我想你的意思是“格式化的日期/时间字符串”,而不是“时间戳”。就是这样。我只需要添加这些信息。非常感谢。我看你已经改变了问题。您并不是要将时间戳转换为格式化的日期/时间字符串,而是相反。