Subtract time in Python

import datetime
print datetime.datetime.now()
print datetime.datetime.now() - datetime.timedelta(minutes=2)
print datetime.datetime.now() - datetime.timedelta(seconds=10)
print datetime.datetime.now() - datetime.timedelta(milliseconds=400)
el@dev ~ $ python test.py
2014-11-26 06:47:07.179411
2014-11-26 06:45:07.179538
2014-11-26 06:46:57.179581
2014-11-26 06:47:06.779614

References
http://stackoverflow.com/questions/13897246/python-time-subtraction

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.