只是一个有关在php.net上找到的setlocale信息的问题 http://php.net/manual/en/function.setlocale.php
它说:
Note:
On Windows, setlocale(LC_ALL, '') sets the locale names from the system's regional/language settings (accessible via Control Panel).
这是否意味着如果我将setlocale(LC_ALL,``)添加到我的PHP中,它应该与我的系统位于同一本地吗?因为我已经做到了,而且几个月后还是英文。
当我回显setlocale(LC_ALL,0)时,我得到了:
LC_COLLATE=C;LC_CTYPE=Norwegian (Bokm�l)_Norway.1252;LC_MONETARY=C;LC_NUMERIC=C;LC_TIME=C
当我回显setlocale(LC_ALL,'')时,我得到了:
Norwegian (Bokm�l)_Norway.1252
所以我真的不知道从回声中看该怎么做,它看起来像是设置为挪威语,当我使用setlocale(LC_ALL,'')时,我也应该将所有内容都设置为挪威语,包括时间,但事实并非如此。 / p>
这也是我用来更改时间格式的代码。
date('d.F', strtotime($row['date2']))
答案 0 :(得分:0)
解决方案:使用strftime()
代替strtotime()
。
strtotime
未考虑设置的语言环境。
之前:
date('d.F', strtotime($row['date2']))
Output: 17.February
之后:
setlocale(LC_ALL, '');
strftime('%e.%B',strtotime($row['date2']))
Output: 17.februar