PHP date and setlocale do not always work

南笙酒味 提交于 2019-12-04 05:16:23

问题


After generating the required locale on our development server and using setlocale to provide PHP with the locale to use the dates formatted with strftime would appear fully translated, as expected.

After reloading the page however, the dates were shown in the server's default locale: en_US. Reloading the pages multiple times resulted in almost a 50/50 chance of the dates being translated. Weird. What is happening here?


回答1:


It appears that both Apache and Nginx webservers need to be restarted after having locales generated for them to be able to use them without problems.

Either use service apache2 restart or service nginx restart to fix the problem. In some cases the entire server might need a restart to fix the problem.

Thanks to Helmut Strasser's blog post we were able to identify the problem.



来源:https://stackoverflow.com/questions/24654379/php-date-and-setlocale-do-not-always-work

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