你好,我正在使用Facebook Graph API,需要获取一个群组中所有帖子的信息。我已经完成了这个任务,并看到了 [created_date'] => '2013-01-25T00:11:02+0000'
这个日期和时间代表什么?我的意思是,我知道2013-01-25
是日期,00:11:02
是时间,但是 T
和 +0000
代表什么?
顺便问一下,Facebook的服务器在哪里?我应该使用哪个时间戳来匹配Facebook的时间?
谢谢。
你好,我正在使用Facebook Graph API,需要获取一个群组中所有帖子的信息。我已经完成了这个任务,并看到了 [created_date'] => '2013-01-25T00:11:02+0000'
这个日期和时间代表什么?我的意思是,我知道2013-01-25
是日期,00:11:02
是时间,但是 T
和 +0000
代表什么?
顺便问一下,Facebook的服务器在哪里?我应该使用哪个时间戳来匹配Facebook的时间?
谢谢。
T表示时间,而+0000是时区偏移量。Facebook使用本地化的时区。您可以通过在Graph API调用中添加参数date_format=U来请求Unix时间戳而不是字符串。
更多信息请参见此链接。
ISO 8601
。字母T
用于明确地分隔日期和时间,+0000
用于表示时区偏移量,此处为GMT或UTC。strtotime()
将其转换为时间戳:$ts = strtotime('2013-01-25T00:11:02+0000');
DATE_ISO8601
和gmdate()
函数。echo gmdate(DATE_ISO8601, $ts);
DateTime
:// import date
$d = DateTime::createFromFormat(DateTime::ISO8601, '2013-01-25T00:11:02+0000');
// export date
echo $dd->format(DateTime::ISO8601), PHP_EOL;
DateTime::createFromFormat()
自 5.3.0 版本开始可用。 - Raptor因此,在您的情况下,The dateTime is specified in the following form "YYYY-MM-DDThh:mm:ss" where:
YYYY indicates the year MM indicates the month DD indicates the day T indicates the start of the required time section hh indicates the hour mm indicates the minute ss indicates the second
To specify a time zone, you can either enter a dateTime in UTC time by adding a "Z" behind the time - like this:
2002-05-30T09:30:10Z
or you can specify an offset from the UTC time by adding a positive or negative time behind the time - like this:
2002-05-30T09:30:10-06:00
or
2002-05-30T09:30:10+06:00
+0000
表示与 UTC 的时间偏移量为 0。
ISO 8601
。 - Ja͢ck