import time import datetime threeDayAgo = (datetime.datetime.now() - datetime.timedelta(days=3)) timeStamp = int(time.mktime(threeDayAgo.timetuple())) otherStyleTime = threeDayAgo.strftime("%Y-%m-%d %H:%M:%S") print(otherStyleTime)
运行结果:
import time import datetime threeDayAgo = (datetime.datetime.now() - datetime.timedelta(days=3)) timeStamp = int(time.mktime(threeDayAgo.timetuple())) otherStyleTime = threeDayAgo.strftime("%Y-%m-%d %H:%M:%S") print(otherStyleTime)
运行结果: