Get yesterday's date
Jim Wight
J.K.Wight at ncl.ac.uk
Wed Nov 27 11:48:37 EST 2002
"Mike C. Fletcher" <mcfletch at rogers.com> writes:
> mxDateTime is often used (and is probably the easiest approach):
>
> >>> from mx.DateTime import *
> >>> now()
> <DateTime object for '2002-11-27 05:27:05.00' at 1630918>
> >>> now()+ RelativeDateTime( days=-1, hour=0, minute=0, second=0 )
> <DateTime object for '2002-11-26 00:00:00.00' at 16880c0>
> >>> now()+RelativeDateTime( days=-1 )
> <DateTime object for '2002-11-26 05:28:40.00' at 16881d0>
> >>> (now()+ RelativeDateTime( days=-1, hour=0, minute=0, second=0
> )).ticks()
> 1038286800.0
Or plain old time:
>>> import time
>>> time.localtime()[:3]
(2002, 11, 27)
>>> time.localtime(time.time()-24*60*60)[:3]
(2002, 11, 26)
>>>
Jim
More information about the Python-list
mailing list