tags:

views:

79

answers:

3

I have the following snippet of code:

setlocale(LC_ALL, "de");
print(strftime("%A %e %B %Y", time()));

and it's printing

Tuesday 4 May 2010

instead of

Dienstag 4. Mai 2010

Any ideas why? How to fix?

+2  A: 

Do you have the de locale available; what does setlocale return for you? See: return values for setlocale().

Also, check the list of available locales (e.g. locale -a or whatever is suitable for your OS) to see if de is among them. Likely alternatives include de_DE or de_DE.utf8 to name a few.

In Debian, to generate a new locale, run this command:

dpkg-reconfigure locales

and pick the ones you want.

salathe
+3  A: 

Setting the locale will have no effect if the locale is not installed on your system.

Ignacio Vazquez-Abrams
+2  A: 

Try setting LC_ALL to "de_DE". On my system it wouldn't work until I did that.

$ LC_ALL=de date
Tue May  4 07:40:13 CDT 2010
$ LC_ALL=de_DE date
Di 4. Mai 07:39:27 CDT 2010
amphetamachine