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
  • 31,366
  • 9
  • 86
  • 97
user1757703
  • 2,755
  • 5
  • 39
  • 59

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,043
  • 20
  • 72
  • 79
2

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

Roland Smith
  • 39,308
  • 3
  • 57
  • 86
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,407
  • 1
  • 29
  • 38