0

I am trying to parse the following date time:

stripped_most_recent = 2017-03-22 14:07:50.000Z

timestamp = (datetime.datetime.strptime(str(stripped_most_recent), "%Y-%m-%d %H:%M:%S.%f"))

Returns the following error:

ValueError: time data '2017-03-22 14:07:50' does not match format '%Y-%m-%d %H:%M:%S.%f'

Whereas, this timestamps causes no problems at all:

2017-03-22 14:07:30.181Z

I have seen this answer here, but dont understand why .000 does not work, whereas anything else is fine.

I think the solution is to remove the .000 completely from the string? As per this answer: What is the best way to do this?

Thanks,

PS I have also tried:

timestamp = (datetime.datetime.strptime(str(stripped_most_recent), "%Y-%m-%d %H:%M:%S.%fZ"))

Community
  • 1
  • 1
archienorman
  • 1,434
  • 3
  • 20
  • 36
  • Possible duplicate of [How do you convert YYYY-MM-DDTHH:mm:ss.000Z time format to MM/DD/YYYY time format in Python?](http://stackoverflow.com/questions/214777/how-do-you-convert-yyyy-mm-ddthhmmss-000z-time-format-to-mm-dd-yyyy-time-forma) – Stephen Rauch Mar 27 '17 at 04:45
  • The accepted answer in the duplicate question answers your question. – Stephen Rauch Mar 27 '17 at 04:46

0 Answers0