12
# datetime模块可以看成是时间加减的模块import datetime
# 返回当前时间print(datetime.datetime.now())
1
2019-03-07 16:22:14.544130
print(datetime.date.fromtimestamp(time.time()))
2019-03-07
# 当前时间+3天print(datetime.datetime.now() + datetime.timedelta(3))
2019-03-10 16:22:14.560599
# 当前时间-3天print(datetime.datetime.now() + datetime.timedelta(-3))
2019-03-04 16:22:14.568473
# 当前时间-3小时print(datetime.datetime.now() + datetime.timedelta(hours=3))
2019-03-07 19:22:14.575881
# 当前时间+30分钟print(datetime.datetime.now() + datetime.timedelta(minutes=30))
2019-03-07 16:52:14.585432
123
# 时间替换c_time = datetime.datetime.now()print(c_time.replace(minute=20, hour=5, second=13))
2019-03-07 05:20:13.595493