Files
30-seconds-of-code/snippets/days_from_now.md
Isabelle Viktoria Maciohsek 7b576c1aa5 Add days_from_now
2020-10-28 16:19:51 +02:00

372 B

title, tags
title tags
days_from_now date,intermediate

Calculates the date of n days from today.

  • Use datetime.date.today() to get the current day.
  • Use datetime.timedelta to add n days from today's date.
from datetime import timedelta, date

def days_from_now(n):
  return date.today() + timedelta(n)
days_from_now(5) # date(2020, 11, 02)