[Python-Dev] How do you get yesterday from a time object
pdecat at gmail.com
Tue Apr 19 18:07:17 CEST 2005
Hi, I believe it's not the appropriate place to ask such questions.
You should check the Python users' list (
Anyway, here you go :
now = time.time()
nowTuple = time.localtime(now)
yesterdayTuple = time.localtime(now-60*60*24)
2005/4/19, Ralph Hilton <flinkkettel at yahoo.com>:
> i'm a beginning python programmer.
> I want to get the date for yesterday
> nowTime = time.localtime(time.time())
> print nowTime.
> oneDay = 60*60*24 # number seconds in a day
> yday = nowTime - oneDay # <-- generates an error
> print yday.strftime("%Y-%m-%d")
> How can I just get yesterday's day? It a simple
> concept yet it seems to be so hard to figure out.
> What i'm worried about is if today is say
> June 1, 2023
> what is yesterday? and how do i compute that?
> Ralph Hilton
> Do you Yahoo!?
> Plan great trips with Yahoo! Travel: Now over 17,000 guides!
> Python-Dev mailing list
> Python-Dev at python.org
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/pdecat%40gmail.com
More information about the Python-Dev