开发者

Current Culture and OS date configuration

开发者 https://www.devze.com 2023-03-19 09:21 出处:网络
I have a very tricky question here. I\'ve been benging my head on this issue for several hours with no success.

I have a very tricky question here. I've been benging my head on this issue for several hours with no success.

I am building an application t开发者_如何学Goo be deployed on numerous machines, with different cultures. As a precautionary I decided to use the Culture class to help convert between string to dates. I noticed that when I change my windows operation system date from :

10/07/2011 to 10-07-2011

The CurrentCulture doesn't get updated, I keep seeing the dates as 10/07/2011. Why is that? Is there any workaround?


You need to change the Culture in the IIS environment (or better in Web.config) and not in the OS. that way you'll Guarantee that all the machines will work on the same Culture.

try to add the following line to your web.config:

<globalization culture="he-IL" enableClientBasedCulture="false" uiCulture="he-IL" />

just change the he-IL to your proffered culture


It works correctly for me, but only after I restart my application. I assume the current culture is loaded at the start of the application and cached, so, for the change to take effect, you have to restart the application.


A long as the value can still be interpreted as a date, it will always be formatted to your CurrentCulture. This is by design.

You need to explicitly change CurrentCulture, so data shows (or is converted) to a new format. Look at CurrentCulture as how data is going to be displayed on your end.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号