0

Im trying to convert a date time into a human friendly format but keep getting errors in the conversion, im not what im missing to match the current format.

I think its 7930000Z thats causing the issue, everything else seems straight forward.

Ive tried, %fZ and %SZ, no luck thus far

>>> datetime.strftime(datetime.strptime('2017-09-18T21:20:33.7930000Z', '%Y-%m-%dT%H:%M:%S.%fZ'),'%d/%m/%y %H:%M:%S')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python3.6/_strptime.py", line 565, in _strptime_datetime
    tt, fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.6/_strptime.py", line 362, in _strptime
    (data_string, format))
ValueError: time data '2017-09-18T21:20:33.7930000Z' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'
AlexW
  • 2,843
  • 12
  • 74
  • 156

1 Answers1

1

Maybe %f is for microseconds and they are "Between 0 and 999999 inclusive"(https://docs.python.org/3/library/datetime.html)

And a post about nanoseconds parsing: Format Nanoseconds in Python

Benjamin
  • 3,350
  • 4
  • 24
  • 49