0

I am getting a DateTime from an API that is formatted as such:

2015-11-27T21:05:03Z

What does the T mean? Does it just a signify that the time is next in the string? Through some searching I found that the Z might mean the zulu time zone or UTC+0:00. Is this even right? How would I go about parsing this in PHP to get it into a SQL DateTime? I bet this is a basic question but I'm having trouble even coming up with good search terms for google.

jlrosenberg
  • 287
  • 4
  • 14
  • This [stackoverflow](http://stackoverflow.com/questions/136782/convert-from-mysql-datetime-to-another-format-with-php) and [php documentation](http://php.net/manual/en/datetime.format.php) should answer your questions. – ordonezalex Jan 13 '16 at 04:18
  • I already know how to format dates based on what is provided in the documentation that you linked. The T and Z in my date is throwing me off and is not mentioned in either link. – jlrosenberg Jan 13 '16 at 04:24
  • Sorry, I could have picked better links. `T` means the time is next according to [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), and `Z` means [Zulu time](https://en.wikipedia.org/wiki/Coordinated_Universal_Time#Time_zones). – ordonezalex Jan 13 '16 at 04:27
  • Okay great thanks! I figured it was something simple but just didn't know how to google this kind of question. – jlrosenberg Jan 13 '16 at 04:29

2 Answers2

1

According to ISO 8601, T delimits date and time.

Alexander Dunaev
  • 980
  • 1
  • 15
  • 40
0

Z is a special UTC designator, times are expressed in UTC (Coordinated Universal Time) uses it for the zero UTC offset. When a time zone designator is used, T is used as a delimiter also its and a valid time expression.

Using php strtotime should do it. Try

strtotime('2015-11-27T21:05:03Z');

PHP datetime formats compound

PoX
  • 1,229
  • 19
  • 32