应用场景,当天操作什么不能超过数量限制,redis里面的过期时间秒差
#当前时间到当天0点的秒差
def exp_second():
#当前时间戳
now_stamp = int(time.time())
print(now_stamp)
#过期为当前日期+1天 的 00:00:00
exp_datetime = (datetime.now() + timedelta(days=1)).strftime("%Y-%m-%d 00:00:00")
exp_stamp = int(time.mktime(time.strptime(exp_datetime, "%Y-%m-%d %H:%M:%S")))
print(exp_stamp)
#时间戳相减得到至当晚0点的妙差
exp_second = exp_stamp - now_stamp
print(exp_second)
return exp_second