Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setlocale having no effect in PHP

Tags:

php

locale

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?

like image 281
pupeno Avatar asked May 04 '10 12:05

pupeno


1 Answers

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.

like image 57
salathe Avatar answered Oct 21 '22 20:10

salathe