[Tutor] Through a glass, darkly: the datetime module

Walter Prins wprins at gmail.com
Fri Oct 5 16:15:19 CEST 2012


Hi Richard

On 5 October 2012 14:47, Richard D. Moores <rdmoores at gmail.com> wrote:
> I thought it would be useful to have a script that would tell me what
> the date n days from today would be. The docs
> (<http://docs.python.org/py3k/library/datetime.html#module-datetime>)
> seem to get me almost there. I can compute the number of days between
> 2 dates, and the number of days between a date and today:

Does this hint help?

>>> import datetime
>>> mydate = datetime.date(2012,10,5)
>>> mydate = mydate + datetime.timedelta(days=30)
>>> print mydate
2012-11-04
>>>


Walter


More information about the Tutor mailing list