Search code examples
djangodatetimedjango-modelsfieldstrptime

How would I convert this datetime format into a DateTimeField using datetime.strptime()?


I have a list of strings formatted as follows: 10:00am - Tuesday, March 16, 2021'

I have been messing around with datetime.strptime() and am not sure how to convert this correctly since it includes the name of the day of the week as well as the actual date.


Solution

  • datetime.strptime(date_time_string, '%I:%M%p - %A, %B %d, %Y') seems to be working.