A problem with Time

Neil Cerutti horpner at yahoo.com
Thu Aug 16 17:59:33 CEST 2007


On 2007-08-16, Shawn Milochik <Shawn at Milochik.com> wrote:
> import time
>
>
> oneDay = 60 * 60 * 24 #seconds in one day
>
> date = time.time()
>
> yesterday = date - oneDay

Or use a timedelta.

>>> import datetime
>>> yesterday = datetime.datetime.today() - datetime.timedelta(days=1)
>>> yesterday.strftime('%m%d%Y')
'08152007'

-- 
Neil Cerutti
It might take a season, it might take half a season, it might take a year.
--Elgin Baylor



More information about the Python-list mailing list