How to create a DateTime equal to 15 minutes ago?
This is simply what to do:
datetime.datetime.now() - datetime.timedelta(minutes = 15)
timedelta
s are specifically designed to allow you to subtract or add deltas (differences) to datetime
s.
datetime.datetime.now() - datetime.timedelta(minutes=15)
import datetime and then the magic timedelta stuff:
In [63]: datetime.datetime.now()
Out[63]: datetime.datetime(2010, 12, 27, 14, 39, 19, 700401)
In [64]: datetime.datetime.now() - datetime.timedelta(minutes=15)
Out[64]: datetime.datetime(2010, 12, 27, 14, 24, 21, 684435)