I have a str that I want to convert to a datetime. This str is this: 'Thursday, September 9, 2021 at 11:50 AM CDT. I am using the datetime.strptime() function, but it seems like the AM or time zone is not being recognized.
When I use the code
time = 'Thursday, September 9, 2021 at 11:50 AM CDT'
time = datetime.strptime(time, '%A, %B %d, %Y at %I:%M %p %Z')
I get the following:
ValueError: time data 'Thursday, September 9, 2021 at 11:50 AM CDT' does not match format '%A, %B %d, %Y at %I:%M %p %Z:%M %p %Z'
I've been able to convert the first part up until the %p %Z part, at which I get the following error:
ValueError: time data 'AM CDT' does not match format '%p %Z'
Any ideas on how dt.strptime() can recognize AM/PM and the time zone correctly?