how to convert ISO 8601 to Date time(Utc) in Python

Question:

I have time stamp in ISO format "2022-06-19T00:00:00+00:00"

and want to convert it in to Date time(utc) format "Jun 19, 2022"

Asked By: ren

||

Answers:

This can be done using the built-in datetime module:

import datetime as dt

input_string = '2022-06-19T00:00:00+00:00'
date = dt.datetime.fromisoformat(input_string)
print(date.strftime('%b %d, %Y'))
Answered By: Michal Racko
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.