tomorrow in yyyymmdd format
Gerhard Häring
gerhard at bigfoot.de
Tue Jun 18 18:34:40 EDT 2002
Giulio Cespuglio wrote in comp.lang.python:
> Hello everybody,
>
> We all know that if I want to get the present GMT date in yyyymmdd
> format I should say
>
> print time.strftime("%Y%m%d", time.gmtime() )
>
> Now, what about tomorrow? Note that a simple string manipulation is
> not the solution I'm looking for, as tomorrow might be next month,
> next year, the 29th of February and such.
> Do you confirm that there's nothing better than the following
> silly-looking expression?
>
> time.strftime("%Y%m%d", time.gmtime(time.time() + 60*60*24))
No, there's nothing better. Unless you're using the DateTime type from
the eGenix mxExtensions:
>>> import mx.DateTime as DateTime
>>> DateTime.today()
<DateTime object for '2002-06-19 00:00:00.00' at 81274e0>
>>> print DateTime.today()
2002-06-19 00:00:00.00
>>> print DateTime.today() + 1
2002-06-20 00:00:00.00
>>>
Gerhard
--
mail: gerhard <at> bigfoot <dot> de registered Linux user #64239
web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9 3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))
More information about the Python-list
mailing list