php facebook创建日期中使用的时间格式是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14516792/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 07:26:12  来源:igfitidea点击:

What is the time format used in facebook created date?

phpfacebookfacebook-graph-apidatetime

提问by Genius in trouble

Hi i am working on facebook Graph API where i need all the posts information of a group. So I did it and saw [created_date'] => '2013-01-25T00:11:02+0000'what does this date and time represent i mean i know 2013-01-25is date and 00:11:02is time but what does Tand +0000represent.

嗨,我正在开发 facebook Graph API,我需要一个群组的所有帖子信息。所以,我做到了,只见[created_date'] => '2013-01-25T00:11:02+0000'这是什么日期和时间,代表我的意思是,我知道 2013-01-25是日期00:11:02是时间,但什么T+0000代表。

BTW where is the server of facebook. Which timestamp should i use to match facebook time?

顺便说一句,facebook的服务器在哪里。我应该使用哪个时间戳来匹配 Facebook 时间?

Thank you.

谢谢你。

回答by BBagi

T = TIME and the +0000 is timezone offset. Facebook uses localized timezones. You can request a Unix timestamp instead of the string by adding the parameter: date_format=U to your graph API call.

T = TIME,+0000 是时区偏移量。Facebook 使用本地化时区。您可以通过在图形 API 调用中添加参数 date_format=U 来请求 Unix 时间戳而不是字符串。

Please see this linkfor more information.

请参阅此链接了解更多信息。

回答by Ja?ck

The date format is called ISO 8601. The letter Tis used to separate date and time unambiguously and +0000is used to signify the timezone offset, in this case GMT or UTC.

日期格式称为ISO 8601. 该字母T用于明确分隔日期和时间,+0000并用于表示时区偏移量,在本例中为 GMT 或 UTC。

That said, you generally don't need to worry so much about the actual contents; rather you should know how to work with them. To use such a date, you can use strtotime()to convert it into a time-stamp:

也就是说,您通常不需要担心实际内容。相反,您应该知道如何与他们合作。要使用这样的日期,您可以使用strtotime()将其转换为时间戳:

$ts = strtotime('2013-01-25T00:11:02+0000');

To convert the time-stamp back into a string representation, you can simply use gmdate()with the predefined date constant DATE_ISO8601:

要将时间戳转换回字符串表示形式,您可以简单地使用gmdate()预定义的日期常量DATE_ISO8601

echo gmdate(DATE_ISO8601, $ts);

Alternatively, using DateTime:

或者,使用DateTime

// import date
$d = DateTime::createFromFormat(DateTime::ISO8601, '2013-01-25T00:11:02+0000');

// export date
echo $dd->format(DateTime::ISO8601), PHP_EOL;

回答by lc.

This is a standard format, specifically ISO 8601.

这是一种标准格式,特别是ISO 8601

As much as I don't like linking to it, http://www.w3schools.com/schema/schema_dtypes_date.aspdoes have a good "human-understandable" explanation:

尽管我不喜欢链接到它,但http://www.w3schools.com/schema/schema_dtypes_date.asp确实有一个很好的“人类可以理解的”解释:

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

日期时间以以下形式指定“YYYY-MM-DDThh:mm:ss”,其中:

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

要指定时区,您可以通过在时间后面添加“Z”来输入 UTC 时间的日期时间 - 如下所示:

2002-05-30T09:30:10Z

或者您可以通过在时间后面添加正时间或负时间来指定与 UTC 时间的偏移量 - 如下所示:

2002-05-30T09:30:10-06:00

或者

2002-05-30T09:30:10+06:00

Therefore, in your case the +0000indicates a time offset of 0 from UTC.

因此,在您的情况下,+0000指示与 UTC 的时间偏移量为 0。