Convert RFC3339 Format to Standard Date/Time

149 Views Asked by At

Been searching through a lot of posts but I can't seem to grasp how to simply convert RFC3339 String Format from API Call to Standard Central Time Zone. Here is what I am trying to do:

from datetime import datetime, timedelta
from pytz import timezone
import pytz

#Initial Value from API
eventStart = "2023-10-11T06:10:35Z"

#Convert from String to Datetime
subDateTime = datetime.strptime(eventStart, '%Y-%m-%dT%H:%M:%SZ')

#Setup Central Timezone
utc = pytz.utc
central = timezone('US/Central')

cstTime = central.localize(subDateTime)
print(cstTime)

cstTime = 2023-10-11 06:10:35-05:00

I am now trying to convert this to look like: 10-11-2023 1:10

I am sure there is a far more efficient way to do what I am trying above. Thank you!

0

There are 0 best solutions below