Strftime with German Date

僤鯓⒐⒋嵵緔 提交于 2019-12-10 16:01:43

问题


im trying to print the date in german with strftime. I 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 it didnt work. Am I missing something?

Edit: sorry I missed the strftime funciton :P


回答1:


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 see what's available.




回答2:


You'll need the Internationalization extension installed, but I recommend using the IntlDateFormatter class

Have a 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());

Which outputs this:

Donnerstag, 15. Dezember 2011



来源:https://stackoverflow.com/questions/8521388/strftime-with-german-date

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!