I am looking to convert "Thu Jul 09 17:05:42 +0000 2020" this string into ISO format in Python. I searched on internet but didn't find any useful information.
You can create a datetime
object from the given string and then use the datetime.isoformat()
to convert it to ISO format.
from datetime import datetime
mydate = datetime.strptime("Thu Jul 09 17:05:42 +0000 2020", "%a %b %d %H:%M:%S %z %Y")
print(mydate.isoformat())
Output:
2020-07-09T17:05:42+00:00
You can read more about formatting the date from the documentation