get "yesterday's" date in iso format

necromancer_stupidspambot at quanta1.world-vr_stupidspambot.com necromancer_stupidspambot at quanta1.world-vr_stupidspambot.com
Fri Jan 23 05:13:56 CET 2004


Hi,

I am trying to find a simple way to get "yesterday's" date.  I know I can
build various check to seee if we are in leap year, if we are the 1st then
yesterday is the 31(or 30 depending of the month) etc. but there is got to
be a simpler way than that. I was thinking of using the gmtime (field 7 as
you can see int the code)then substract one, then use strptime to rebuild
the time but it doesn't work(probably because I misunderstood strptime):

improt time
gmt = time.gmtime()
yesterdaytime = str(int(gmt[7]) - 1)
print gmt[7]
print yesterdaytime
newtime = time.strptime(yesterdaytime,'%j')
print newtime
(1900, 1, 22, 0, 0, 0, 0, 22, -1)

can someone enlighten me please?

Thanks
David




More information about the Python-list mailing list