How do you get yesterday from a time object
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! http://travel.yahoo.com/p-travelguide
On 4/19/05, Ralph Hilton
i'm a beginning python programmer.
I want to get the date for yesterday
This is the wrong place for this question. Nip over to http://mail.python.org/mailman/listinfo/python-list, and I'd be more than happy answer it there... -- Cheers, Simon B, simon@brunningonline.net, http://www.brunningonline.net/simon/blog/
On 4/19/05, Ralph Hilton
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?
You don't want the python-dev list for this type of question. Python-dev is for development *of* Python. For usage questions such as this, you would be better asking on python-list (or, equivalently, the Usenet group comp.lang.python). To assist with your question, though, I'd suggest you look at the documentation of the datetime module, which allows you to do what you are after (and much more). Regards, Paul
Hi, I believe it's not the appropriate place to ask such questions.
You should check the Python users' list (
http://python.org/community/lists.html )
Anyway, here you go :
now = time.time()
nowTuple = time.localtime(now)
yesterdayTuple = time.localtime(now-60*60*24)
Regards,
Patrick.
2005/4/19, Ralph Hilton
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! http://travel.yahoo.com/p-travelguide _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/pdecat%40gmail.com
participants (4)
-
Patrick DECAT
-
Paul Moore
-
Ralph Hilton
-
Simon Brunning