6

I have a Web Application which at various points makes users enter dates and also displays dates to users. When debugging (and when the site is running on our test and staging servers) the date formats appear in dd/mm/yyyy format (when using DateTime.ToShortDateString()). These servers (and my dev environment have "English (United Kingdom)" set as the language under the windows regional options. All good so far. However, on the live server dates appear in the format mm/dd/yyyy even though the live server still has the language set to "English (United Kindgom)". I've seen this question which explains how to parse the date in a specific format and I already know how to get the date in the required string format (DateTime.ToString("dd/MM/yyyy")) but am wondering what other OS setting on the live server is causing this discrepancy? I've also seen this question, but it doesn't seem to answer my question.

Some additional information: on the dev, test and staging environments System.Threading.Thread.CurrentThread.CurrentUICulture.Name="en-US" System.Threading.Thread.CurrentThread.CurrentCulture.Name="en-GB"

And on the live environment System.Threading.Thread.CurrentThread.CurrentUICulture.Name="en-US" System.Threading.Thread.CurrentThread.CurrentCulture.Name="en-US"

4 Answers 4

9

Have you checked the globalization section of web.config?

You can set it declaratively like so:

    <globalization uiCulture="en-GB" culture="en-GB" />

See: http://msdn.microsoft.com/en-us/library/bz9tc508.aspx

1
  • Aah right, just checked and there wasn't one. I've added <globalization culture="en-gb"/> under <system.web> and it seems to work fine now. Thank you! May 19, 2011 at 9:58
3

Regional Settings apply on a per-user basis - so you need to ensure that you change the regional settings for whichever user IIS is running your application under, e.g. Network Service.

Looks like many others have searched for ways to do this (google "IIS change regional settings"). It looks like most people achieve it by hacking the settings into the appropriate part of the registry (under HKEY_USERS\IUSR-SID\Control Panel\International)

1
1

You can of course override this in the Begin Request event.

But the real underlying reason is that Windows is not localised into English. We get American English: there is no resource localisation to en-GB, so this setting avoids lots of failed lookups for en-GB resources immediately falling back to en-US.

-3

Try checking the Locale used on the live server. check the below link for more details

http://www.java.com/en/download/help/locale.xml

you may also need to check the language priority listed in the Browser.

Regards

1
  • This question was regarding ASP.NET, not Java May 19, 2011 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.