python实现当前时间后推三个月
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python实现当前时间后推三个月,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2802字,纯文字阅读大概需要5分钟。
内容图文
![python实现当前时间后推三个月](/upload/InfoBanner/zyjiaocheng/615/5eee4c4addfc446fafc706727d677717.jpg)
由当前时间向后推3个月
def index_time():
end_time = time.time()
end_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end_time))
date_list_1 = end_date.split('-')
date_list_2 = date_list_1[2].split(' ')
date_d = date_list_2[0]
date_Y = date_list_1[0]
date_m = date_list_1[1]
print('当前的年份', date_Y)
print('当前的月份', date_m)
print('当前日期',date_d)
if int(date_Y) % 4 == 0:
print('润年2月29天')
if date_m in ['1', '2', '6', '8', '9', '10', '11']:
if date_d in ['31']:
start_time = end_time - 86400 * 93
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
else:
start_time = end_time - 86400 * 92
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
elif date_m in ['3', '4', '7', '12']:
if date_d in ['31']:
start_time = end_time - 86400 * 92
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
else:
start_time = end_time - 86400 * 91
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
else:
if date_d in ['30']:
start_time = end_time - 86400 * 91
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
elif date_d in ['31']:
start_time = end_time - 86400 * 92
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
else:
start_time = end_time - 86400 * 90
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
else:
print('非润年2月28天')
if date_m in ['1', '2', '6', '8', '9', '10', '11']:
if date_d in ['31']:
start_time = end_time - 86400 * 93
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
else:
start_time = end_time - 86400 * 92
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
elif date_m in ['7', '12']:
if date_d in ['31']:
start_time = end_time - 86400 * 92
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
else:
start_time = end_time - 86400 * 91
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
elif date_m in ['3', '4']:
if date_d in ['31']:
start_time = end_time - 86400 * 91
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
else:
start_time = end_time - 86400 * 90
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
else:
if date_d in ['29']:
start_time = end_time - 86400 * 90
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
elif date_d in ['30']:
start_time = end_time - 86400 * 91
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
elif date_d in ['31']:
start_time = end_time - 86400 * 92
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
else:
start_time = end_time - 86400 * 89
start_date = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
print('开始时间', start_date)
print('开始时间', end_date)
return end_date, start_date
内容总结
以上是互联网集市为您收集整理的python实现当前时间后推三个月全部内容,希望文章能够帮你解决python实现当前时间后推三个月所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。