如何使用datetime Python模块从当前日期计算六个月的日期? [英] How do I calculate the date six months from the current date using the datetime Python module?

查看:380
本文介绍了如何使用datetime Python模块从当前日期计算六个月的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用datetime Python模块。我正在计算从当前日期起6个月的日期。有人可以给我一点帮助吗?



我想从当前日期起6个月生成一个日期的原因是产生一个审查日期。如果用户将数据输入到系统中,它将从其输入数据之日起6个月的审核日期。

解决方案

  import datetime 
print(datetime.date.today() datetime.timedelta(6 * 365/12))。isoformat()


I am using the datetime Python module. I am looking to calculate the date 6 months from the current date. Could someone give me a little help doing this?

The reason I want to generate a date 6 months from the current date is to produce a Review Date. If the user enters data into the system it will have a review date of 6 months from the date they entered the data.

解决方案

import datetime
print (datetime.date.today() + datetime.timedelta(6*365/12)).isoformat()

这篇关于如何使用datetime Python模块从当前日期计算六个月的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆