strftime - %a is always Monday ?

Gerrit Holl gerrit at
Mon Dec 29 14:39:13 CET 2003

Richard Shea wrote:
> Hi - I'm trying to use strftime to output the day of the week but I
> find that I always get told it's Monday. I have tried day, month, year
> etc and all come out correctly but as soon as I use %a I get 'Mon'.
> I'm running Python 2.3.2 on a Windows 98 machine. Can anyone suggest
> what the problem might be please ?
> This is a segment of the code which is manfests the behaviour ...
> >>> from time import localtime,strftime,time
> >>> lst1 = ['2003','12','27']
> >>> strftime("%A,%d (%w %y
> %m)",[int(lst1[0]),int(lst1[1]),int(lst1[2]),0,0,0,0,0,0])
> 'Monday,27 (1 03 12)'
> >>> 
> ... whereas the 27th was a Saturday ?

time.strftime does not know about dates. Field number 6 specifies the
weekday: make it a 1 and it will say Tuesday, 2->Wednesday, etc. You may
want to use the new datetime module:


131. If a man bring a charge against one's wife, but she is not
surprised with another man, she must take an oath and then may return to
her house.
          -- 1780 BC, Hammurabi, Code of Law
Asperger's Syndrome - a personal approach:

More information about the Python-list mailing list