-2

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"

ren
  • 25
  • 5
  • Does this answer your question? [How do I parse an ISO 8601-formatted date?](https://stackoverflow.com/questions/127803/how-do-i-parse-an-iso-8601-formatted-date) – FObersteiner Sep 04 '22 at 07:27
  • After parsing to datetime object, just `strftime` with desired formatting directive. – FObersteiner Sep 04 '22 at 07:28
  • @FObersteiner any library or method to parse iso to datetime – ren Sep 04 '22 at 07:32
  • @FObersteiner [How do I parse an ISO 8601-formatted date?](https://stackoverflow.com/questions/14882908/convert-iso-8601-datetime-to-utc-time-rails) is in unix time stamp not in iso – ren Sep 04 '22 at 07:35

1 Answers1

3

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'))
Michal Racko
  • 462
  • 2
  • 4