日期时间区域设置

发布于 2024-09-13 05:48:07 字数 221 浏览 0 评论 0 原文

我们的一台应用程序服务器上的日期时间存在问题。 问题是日期时间选择区域设置为 en-US,而我们希望使用 en-GB。 我尝试将服务器区域和语言选项更改为英国,但仍然存在相同的问题。 我可以强制 DateTime 使用 en-GB,但这需要在不同位置更改代码。 我尝试在 web.config 文件中添加全球化设置,但日期时间仍选择为美国。 由于代码在所有其他服务器上都可以正常工作,因此有什么方法可以在该服务器上解决此问题吗?

We are haveing issue with DateTime on one of our application servers.
The issue is the datetime is picking the locale settings as en-US and we want to use en-GB.
I tried to Change the server Regional and Language options to UK still having the same issue.
I could force DateTime to use en-GB but this will require code changes at various location.
I tried to add globalization settings in web.config file still date time is picked as US.
Is there a way I can fix this issue on that server since the code works fine on all other servers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

埋葬我深情 2024-09-20 05:48:07

设置 。设置culture 和uiculture 参数。如果这不起作用,您可以通过 global.asax 设置每个线程的区域设置。

void Application_BeginRequest(object source, EventArgs e)
{
   string Lang = "en-GB";
   System.Threading.Thread.CurrentThread.CurrentCulture = 
      new System.Globalization.CultureInfo(Lang);
}

It should be sufficient to set the <globalization> section in web.config. Set both the culture and uiculture parameter. If that won't work you can set the locale per thread via global.asax.

void Application_BeginRequest(object source, EventArgs e)
{
   string Lang = "en-GB";
   System.Threading.Thread.CurrentThread.CurrentCulture = 
      new System.Globalization.CultureInfo(Lang);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文