Reputation: 1478
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-25
is date and 00:11:02
is time but what does T
and +0000
represent.
BTW where is the server of facebook. Which timestamp should i use to match facebook time?
Thank you.
Upvotes: 13
Views: 34049
Reputation: 2085
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.
Please see this link for more information.
Upvotes: 29
Reputation: 116468
This is a standard format, specifically ISO 8601.
As much as I don't like linking to it, http://www.w3schools.com/schema/schema_dtypes_date.asp does have a good "human-understandable" explanation:
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
Therefore, in your case the +0000
indicates a time offset of 0 from UTC.
Upvotes: 5
Reputation: 173562
The date format is called ISO 8601
. The letter T
is used to separate date and time unambiguously and +0000
is used to signify the timezone offset, in this case GMT or 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:
$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
:
echo gmdate(DATE_ISO8601, $ts);
Alternatively, using DateTime
:
// import date
$d = DateTime::createFromFormat(DateTime::ISO8601, '2013-01-25T00:11:02+0000');
// export date
echo $dd->format(DateTime::ISO8601), PHP_EOL;
Upvotes: 13