Search code examples
pythondatedate-formatstrptime

python time data does not match format with identical mapping


I'm getting the following error:

time data '2017-12-11 10:00:00' does not match format 'Y-m-d H:M:S'

The formatting looks perfect to me.

Here is my code:

start_date = '2017-12-11 10:00:00-08:00' start_date = pytz.timezone(event.time_zone).localize(datetime.strptime(start_date[:-6],'Y-m-d H:M:S'))

Am I missing something?


Solution

  • You should prepend date placeholders with % in your casce it should be datetime.strptime(start_date[:-6],'%Y-%m-%d %H:%M:%S')