date/time

Lee Harr lee at example.com
Wed Jan 5 17:35:21 EST 2005


On 2005-01-05, Nader Emami <emami at knmi.nl> wrote:
> L.S.,
>
> Could somebody help me how I can get the next format of date
> from the time module?
>
> example: I have to have this time 20050105. It is the next
> attributes of format %Y%m%d.
>


I would use the datetime module:


>>> import datetime
>>> today = datetime.date.today()
>>> today
datetime.date(2005, 1, 5)
>>> today.strftime('%Y%m%d')
'20050105'
>>> one_day = datetime.timedelta(1)
>>> tomorrow = today + one_day
>>> tomorrow.strftime('%Y%m%d')
'20050106'





More information about the Python-list mailing list