Search code examples
pythondatetimeiso8601

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


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"


Solution

  • 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'))