gistlib
You can get the date 5 weeks from now by using the timedelta function from the datetime module in Python. Here's the code:
timedelta
datetime
main.pyfrom datetime import date, timedelta today = date.today() # get today's date five_weeks = timedelta(weeks=5) # create a timedelta object for 5 weeks five_weeks_from_now = today + five_weeks # add the timedelta to today's date print(five_weeks_from_now) 258 chars8 lines
from datetime import date, timedelta today = date.today() # get today's date five_weeks = timedelta(weeks=5) # create a timedelta object for 5 weeks five_weeks_from_now = today + five_weeks # add the timedelta to today's date print(five_weeks_from_now)
This code will print the date 5 weeks from now in the format YYYY-MM-DD.
YYYY-MM-DD
gistlibby LogSnag