New Time format
David Glasser
news at davidglasser.net
Sat Jan 26 11:02:09 EST 2002
Dale Strickland-Clark <dale at riverhall.NOTHANKS.co.uk> wrote:
> time.ISOtime(style)
>
> returns a strings the contents of which are determined by style.
>
> style = 0 => "hh:mm:ss"
> style = 1 => "yyyy-mm-dd" (all numeric)
> style = 2 => "yyyy-mmm-dd" (month localised TLA)
> style = 3 => "yyyy-mm-dd hh:mm:ss" (all numeric)
> style = 4 => "yyyy-mmm-dd hh:mm:ss" (month localised TLA)
import time
def ISOtime(style):
thetime = time.localtime(time.time())
if style == 0:
return time.strftime("%H:%M:%S", thetime)
elif style == 1:
return time.strftime("%Y-%m-%d", thetime)
elif style == 2:
return time.strftime("%Y-%b-%S", thetime)
elif style == 3:
return time.strftime("%Y-%m-%d %H:%M:%S", thetime)
elif style == 4:
return time.strftime("%Y-%b-%d %H:%M:%S", thetime)
else:
return "unknown style"
Now you can use this function wherever you want!
--
David Glasser
news at davidglasser.net http://www.davidglasser.net/
More information about the Python-list
mailing list