PHP日期的setlocale并不总是工作 [英] PHP date and setlocale do not always work

查看:153
本文介绍了PHP日期的setlocale并不总是工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

生成我们的开发服务器上所需要的语言环境,并使用的setlocale 来提供PHP的语言环境使用带有的strftime 似乎完全翻译,符合市场预期。

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.

然而重新加载页面后,被显示在服务器的默认语言环境的日期: EN_US 。重装多次导致几乎50/50机会的日期被翻译的页面。奇怪的。这里发生了什么?

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?

推荐答案

看来,两者的的Apache 的和的 Nginx的的Web服务器需要后产生了具有区域设置为他们重新启动能够使用它们没有问题。

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.

或者使用服务的Apache2重启服务nginx的重启来解决这个问题。在一些情况下,整个服务器可能需要重新启动来解决这个问题。

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.

这篇关于PHP日期的setlocale并不总是工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆