- import datetime
- now = datetime.datetime.now()
- print now
- #往後3小時,2天,3分鐘,3秒鐘
- print datetime.datetime.now() + datetime.timedelta(hours=3)
- print datetime.datetime.now() + datetime.timedelta(days=3)
- print datetime.datetime.now() + datetime.timedelta(minutes=3)
- print datetime.datetime.now() + datetime.timedelta(seconds=3)
下面看看效果:
- 2011-11-04 14:07:18.437000
- 2011-11-07 14:07:18.437000
- 2011-11-04 17:07:18.437000
- 2011-11-04 14:10:18.437000
- 2011-11-04 14:07:21.437000