Date formats
Hans Nowak
ivnowa at hvision.nl
Thu Jun 10 15:38:29 EDT 1999
On 10 Jun 99, mike milliger wrote:
> I read the documentation in the Python Reference Library (6.3) on time
> access and conversions and chapter 8 in programming python, yet I can't
> figure out if i need ( or how to use) a tuple to format the return from
> localtime(). i get a string now (wed jun 10 1999 xx:xx:xx) but i need
> to format it to yyyymmdd_hhmmss. Is there any switch ( %) or function
> that can be useful? Any help is appreciated.
You can roll your own:
#
import time
t = time.localtime(time.time())
# prints the tuple
print t
# prints a formatted tuple
print "%d%02d%02d_%02d%02d%02d" % t[0:6]
Disclaimer: This is untested, maybe the format will appear weird...
but you'll get the idea.
Veel liefs,
--Hans Nowak (ivnowa at hvision.nl)
Homepage: http://fly.to/zephyrfalcon
More information about the Python-list
mailing list