Strftime with German date

im trying to print the date in german using strftime. I have already tried

date_default_timezone_set('Europe/Berlin'); setlocale(LC_ALL, "de_DE", " de_DE@euro ", "deu", "deu_deu", "german"); $time = strftime("%B", 1323956220); echo $time; //I want to see "Dezember", but I see "December" instead 

but he did not work. Did I miss something?

Edit: Sorry, I missed the strftime function: P

+4
source share
2 answers

My guess: the locale is actually called de_DE.utf8 on your machine (it is on mine). Does this work for you?

 setlocale(LC_ALL, "de_DE.utf8"); // or LC_TIME echo strftime('%B', 1323956220); 

BTW: On Linux, you can use locale -a to find out what is available.

+11
source

You will need an internationalization extension, but I recommend using the IntlDateFormatter class

Look at the manual first, but a quick example might look like this:

 $fmt = datefmt_create("de_DE", IntlDateFormatter::FULL, IntlDateFormatter::NONE, 'Europe/Berlin', IntlDateFormatter::GREGORIAN); echo datefmt_format($fmt , time()); 

What deduces this:

Donnerstag, 15. Dezember 2011

-1
source

Source: https://habr.com/ru/post/1386529/


All Articles