W3docs

How do I parse an ISO 8601-formatted date?

You can use the datetime.fromisoformat() method to parse an ISO 8601-formatted date in Python.

You can use the datetime.fromisoformat() method to parse an ISO 8601-formatted date in Python. Here is an example:

parse an ISO 8601-formatted date in Python using the datetime.fromisoformat method

python— editable, runs on the server

This will output:


2022-11-15 09:00:00

Note that this method is available on python 3.7+ If you are using python version less than 3.7, you can use dateutil library to parse ISO8601 date string.

parse an ISO 8601-formatted date in Python using the dateutil module

python— editable, runs on the server

This will also output:


2022-11-15 09:00:00