Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

datetime.strptime () throws 'does not match format' error

Tags:

python

django

I get

time data '19/Apr/2011:22:12:39' does not match format '%d/%b/%y:%H:%M:%S'

when using datetime.strptime('19/Apr/2011:22:12:39','%d/%b/%y:%H:%M:%S')

What am I doing wrong?

like image 267
ElyaSh Avatar asked May 05 '11 11:05

ElyaSh


1 Answers

Try %d/%b/%Y:%H:%M:%S instead - %y right now means 11.

You can "debug" datetime formats easily using date (on the shell and not on python, I mean, assuming you're running GNU/Linux or similar):

date '+%d/%b/%Y:%H:%M:%S'
05/May/2011:09:00:41
like image 89
Eduardo Ivanec Avatar answered Oct 03 '22 02:10

Eduardo Ivanec