import datetime nowTime = datetime.datetime.now() print(nowTime) yesterday = nowTime + datetime.timedelta(days = -1) justNow = nowTime + datetime.timedelta(seconds= -1) print("yesterday:",yesterday) print("nowOld:",justNow) Now = datetime.datetime.now() + datetime.timedelta(days = -1) outPut = Now.strftime("%Y/%m/%d %H:%M:%S") print(outPut)