get "yesterday's" date in iso format
Tim Heaney
theaney at cablespeed.com
Thu Jan 22 23:39:07 EST 2004
necromancer_stupidspambot at quanta1.world-vr_stupidspambot.com writes:
>
> 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.
Since time.time() gives the time in seconds since the epoch, you could
just subtract a day from that to get yesterday.
>>> import time
>>> time.gmtime(time.time()-24*60*60)
(2004, 1, 22, 4, 36, 3, 3, 22, 0)
I hope this helps,
Tim
More information about the Python-list
mailing list