Python month specifier datetime.strptime not working

The month format specifier does not work.

from datetime import datetime
endDate = datetime.strptime('10 3 2011', '%j %m %Y')
print endDate
2011-01-10 00:00:00 
endDate = datetime.strptime('21 5 1987', '%j %m %Y')
print endDate 
1987-01-21 00:00:00

Now, according to the manual, the guide :

% m = month as a decimal number [01,12].

So, what am I missing, except for the hair I pulled out, trying to understand why my django __filter requests do not return anything (the dates that occur are invalid!)? I tried 03and to 05no avail.

Versions of things, platform, architecture, etc.:

$ python --version
Python 2.7
$ python3 --version
Python 3.1.2
$ uname -r
2.6.35.11-83.fc14.x86_64 (that Linux/Fedora 14/64-bit).
+3
source share
3 answers

%j , %m, , % j, [001,366], 10 10 , 01 ...

, :

>>> datetime.strptime('10 2011', '%j %Y')
datetime.datetime(2011, 1, 10, 0, 0)

10 , :

>>> datetime.strptime('10 3 2011', '%d %m %Y')
datetime.datetime(2011, 3, 10, 0, 0)
+6

%j " ", strptime 21 , %m?

+3

%j . 10- , 10 , , . , .

+2

All Articles