New Time format
Martin von Loewis
loewis at informatik.hu-berlin.de
Thu Jan 24 15:23:43 EST 2002
Dale Strickland-Clark <dale at riverhall.NOTHANKS.co.uk> writes:
> There is an ISO standard date format, the order of which makes sense
> in most regions: year-month-day hour:minutes:seconds
I'm not sure I understand the problem you seem to have with
time.strftime.
> style = 0 => "hh:mm:ss"
time.strftime("%H:%M:%S", thetime)
time.strftime("%T", thetime)
> style = 1 => "yyyy-mm-dd" (all numeric)
time.strftime("%Y-%m-%d", thetime)
> style = 2 => "yyyy-mmm-dd" (month localised TLA)
time.strftime("%Y-%b-%S", thetime)
> style = 3 => "yyyy-mm-dd hh:mm:ss" (all numeric)
time.strftime("%Y-%m-%d %H:%M:%S", thetime)
> style = 4 => "yyyy-mmm-dd hh:mm:ss" (month localised TLA)
time.strftime("%Y-%b-%d %H:%M:%S", thetime)
> What I'm after is something I can stick in code when I need a
> date/time without having to check the docs for the correct formatting
> sequence.
I'd question that people can memorize the meaning of a number in 0..4
to identitify a format much better than they can memoryize strftime
format specifiers. I'm pretty sure that people can *read*
time.strftime("%Y-%m-%d", time.localtime(time.time()))
better than they can read
time.ISOtime(1)
Regards,
Martin
More information about the Python-list
mailing list