Country specific date format

Diez B. Roggisch deetsNOSPAM at web.de
Fri Oct 8 07:28:04 EDT 2004


Franz Steinhaeusler wrote:

> Hello,
> 
> with following function, i get a human readable date/time format.
> 
> mtime = time.strftime(self.timeformat ,time.localtime(st.st_mtime))
> 
> However is there a simple solution to get a country specific format:
> for example
> 10/08/2004
> 
> and for German:
> 08.10.2004
> 
> I looked in locale class, but I didn't get more wise.

You didn't look properly:

>>> locale.nl_langinfo(locale.D_FMT)
'%m/%d/%y'
>>> locale.setlocale(locale.LC_ALL, 'de_DE')
>>> locale.nl_langinfo(locale.D_FMT)
'%d.%m.%Y'


-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list