Noob | datetime question

Carsten Haese carsten at uniqsys.com
Tue Nov 14 10:44:38 EST 2006


On Tue, 2006-11-14 at 09:33 -0600, Kevin Kelley wrote:
> import time
> FORMAT='%Y%m%d'
> 
> time.strftime(FORMAT,time.gmtime(time.time()+8380800))
> output = '20070219'

While the above works, the following variation using datetime is more
readable:

>>> import datetime
>>> someday = datetime.date.today() + datetime.timedelta(days=97)
>>> print someday.strftime("%Y%m%d")
20070219

-Carsten





More information about the Python-list mailing list