Add one year in current date PYTHON

后端 未结 8 1498
别跟我提以往
别跟我提以往 2020-11-29 01:59

I have fetched a date from database with the following variable

{{ i.operation_date }}

8条回答
  •  盖世英雄少女心
    2020-11-29 02:25

    convert it into python datetime object if it isn't already. then add deltatime

    one_years_later = Your_date + datetime.timedelta(days=(years*days_per_year)) 
    

    for your case days=365.

    you can have condition to check if the year is leap or no and adjust days accordingly

    you can add as many years as you want

提交回复
热议问题