This simple Python script calculates the date that is a specified number of days from the current date.
- Calculate future dates based on the current date and a given number of days.
- Easy to modify for different time spans.
- Python 3.x
- Import the necessary modules:
datetime
andtimedelta
from thedatetime
library. - Get the current date using
datetime.now()
. - Calculate the future date by adding a
timedelta
object, specifying the number of days, to the current date. - Format the future date as desired using
strftime()
.
from datetime import datetime, timedelta
# current date
current_date = datetime.now()
# calculate the date 33 days from now
# change 33 to whichever target date you're interested in
future_date = current_date + timedelta(days=33)
# format the date to display only the day
future_day = future_date.strftime("%A, %B %d, %Y")
print(future_day)
In this example, the script calculates the date that is 33 days from the current date and formats it to display the day of the week, month, day, and year.
This project is licensed under the MIT License - see the LICENSE file for details.