vondip
vondip

Reputation: 14039

Current Culture and OS date configuration

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 to 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?

Upvotes: 2

Views: 295

Answers (3)

Eddie Rozenblat
Eddie Rozenblat

Reputation: 832

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

Upvotes: 1

svick
svick

Reputation: 244787

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.

Upvotes: 1

Alexandre Bell
Alexandre Bell

Reputation: 3241

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.

Upvotes: 0

Related Questions