0

What time format is this 2014-06-14T16:46:01.000Z ?

How can I strftime that into human readable form? I don't recognized what the T and Z mean.

Oleh Prypin
  • 33,184
  • 10
  • 89
  • 99
user1757703
  • 2,925
  • 6
  • 41
  • 62
  • 3
    possible duplicate of [How to parse ISO formatted date in python?](http://stackoverflow.com/questions/127803/how-to-parse-iso-formatted-date-in-python) – Matt Johnson-Pint Jun 22 '14 at 19:04
  • That is a UTC timestamp in [ISO 8601](http://en.wikipedia.org/wiki/ISO-8601) Extended format - also described by [RFC 3339](http://tools.ietf.org/html/rfc3339). – Matt Johnson-Pint Jun 22 '14 at 19:05
  • Answers and thanks shouldn't be a part of the question, so I rolled back. – Oleh Prypin Jun 22 '14 at 19:11
  • @OlehPrypin Sorry didn't know that is disallowed. I just posted my solution after reading this ISO time format in case it could be helpful to others reading from the future. – user1757703 Jun 22 '14 at 19:13

3 Answers3

3

To convert this don't use strftime use date.util

import dateutil.parser
nowdate = dateutil.parser.parse(datestring)

you can also use https://bitbucket.org/micktwomey/pyiso8601

>>> import iso8601
>>> iso8601.parse_date("2007-01-25T12:00:00Z")
datetime.datetime(2007, 1, 25, 12, 0, tzinfo=<iso8601.Utc>)
>>>
Rachel Gallen
  • 27,943
  • 21
  • 72
  • 81
2

It is a combined date and time representation according to ISO 8601.

Roland Smith
  • 42,427
  • 3
  • 64
  • 94
2

You can't run an strftime as it can be applied only on date objects. But you can convert this string to a dateobject using strftime

from datetime import datetime
date = datetime.strptime("2014-06-14T16:46:01.000Z", "%Y-%m-%dT%H:%M:%S.%fZ")
print date

output

2014-06-14 16:46:01

T and Z are designatiors for time and zone

Ashoka Lella
  • 6,631
  • 1
  • 30
  • 39