Reputation: 536
I don't know why but I always seem to have trouble formatting dates with strptime. I really can't see where I am going wrong here but this is the error I got...
time data '2021-04-10 18:00:00' does not match format '%Y-%m-%d %H:%M:%S.'
I appreciate any help you can give.
weatherDate = datetime.datetime.strptime(date, '%Y-%m-%d %H:%M:%S')
Upvotes: 0
Views: 35
Reputation: 171
It does work here:
import datetime
date_str = '2021-04-10 18:00:00'
date = datetime.datetime.strptime(date_str, '%Y-%m-%d %H:%M:%S')
Which gives:
>>> date
datetime.datetime(2021, 4, 10, 18, 0)
Upvotes: 1