Search code examples
pythondatedatetimepython-datetimearrow-python

Convert string to date using arrow python


I'm trying to convert string to date using arrow module. During the conversion, I received this error: arrow.parser.ParserMatchError: Failed to match '%A %d %B %Y %I:%M:%S %p %Z' when parsing 'Wednesday 06 November 2019 03:05:42 PM CDT'

The conversion is done using one simple line according to this documentation:

date = arrow.get(date, '%A %d %B %Y %I:%M:%S %p %Z')

I also try to do this with datetime and got another error:

ValueError: time data 'Wednesday 06 November 2019 03:27:33 PM CDT' does not match format '%A %d %B %Y %I:%M:%S %p %Z'

What am I missing?


Solution

  • Issue is with timezone, hard-coding timezone here works

    import datetime
    datetime.datetime.strptime('Wednesday 06 November 2019 03:05:42 PM CDT', '%A %d %B %Y %I:%M:%S %p CDT')