Date&Time
āļŦāļēāļ§āļąāļāļāļĩāđāļāļąāļāđāļāļāļēāļāļ§āļąāļāļāļĩāđāļāļąāļāļāļļāļāļąāļ
import datetime as dt
def get_date_from_today(delta, strfmt='%Y%m%d'):
""" Returns a string that represents a date n numbers of days from today.
Parameters
----------
delta : int
number of days
strfmt : string
format in which the date will be represented
"""
return (dt.date.today() + dt.timedelta(delta)).strftime(strfmt)delta = 30 # āļāļ§āļāļāļēāļāļ§āļąāļāļāļĩāđāļāļąāļāļāļļāļāļąāļāđāļ 30 āļ§āļąāļ
result = get_date_from_today(delta)
print(result)
# '20200830' [āļ§āļąāļāļāļĩāđāļāļąāļāļāļļāļāļąāļ = 20200731]String to Datetime
Datetime to String
Last updated
Was this helpful?