import time,datetime import dateutil.relativedelta now_time = datetime.datetime.now() pre_time = now_time + dateutil.relativedelta.relativedelta(weeks=-2) print(now_time, pre_time)