问题描述
我在Ubuntu系统上使用Apache和php 7.安装德语语言环境并运行locale -a
以检查已安装的语言环境后,得到C, C.UTF-8, de_DE, de_DE@euro, de_DE.iso88591, de_DE.iso885915@euro, de_DE.utf8, deutsch, en_US.utf8, german, POSIX
.我还使用sudo update-locale
更新了语言环境.但是使用php代码
I am using Apache and php 7 on an Ubuntu System. After installing the german locales and running locale -a
to check the installed locales, I get C, C.UTF-8, de_DE, de_DE@euro, de_DE.iso88591, de_DE.iso885915@euro, de_DE.utf8, deutsch, en_US.utf8, german, POSIX
. I also update the locale using sudo update-locale
. However using the php code
setlocale(LC_ALL,'de_DE');
echo date("F", strtotime("2018-10-10"));
它将返回英文"October",而不是德语"Oktober".我不知道该怎么办...我也重新启动了Apache ...但是什么也没发生.
It returns me the English "October", not the German "Oktober". I have no idea what I can do... I also restarted the Apache... but nothing happened.
推荐答案
date()
函数不监听语言环境-这将仅以英语返回值.
The date()
function doesn't listen to the locales - this will be returning values in English only.
从date()
文档中,
您需要改用strftime()
.
setlocale(LC_ALL,'de_DE');
echo strftime("%B", strtotime("2018-10-10"));
-
strftime()
文档
这篇关于PHP语言环境de_DE返回英语语言环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!