How do I translate an ISO 8601 datetime string into a Python datetime object? [duplicate]

This question already has answers here: How do I parse an ISO 8601-formatted date? (28 answers) Closed 7 years ago. I’m getting a datetime string in a format like “2009-05-28T16:15:00” (this is ISO 8601, I believe). One hackish option seems to be to parse the string using time.strptime and passing the first six elements of … Read more

How do I parse an ISO 8601-formatted date?

I need to parse RFC 3339 strings like “2008-09-03T20:56:35.450686Z” into Python’s datetime type. I have found strptime in the Python standard library, but it is not very convenient. What is the best way to do this? 28 s 28 The datetime standard library has, since Python 3.7, a function for inverting datetime.isoformat(). classmethod datetime.fromisoformat(date_string): Return … Read more