I have a Windows Server 2008 R2 system which is configured with the default locale settings (no overrides on the format or anything) and it's set to en-US.
When I interrogate the following: System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat
It is listing the DateSeparator as a - (dash) instead of a / (slash). So DateTime.Now.ToString() would look something like:
01-30-2015.
Also, the CurrentThread.CurrentCulture.ToString() = "en-US"
I'm completely at a loss as to how this is even possible, but more importantly, I would like to know if .NET has some kind of a locale override which is configurable somehow?
The system Region & Language settings are normal and have not been changed. Any help would be greatly appreciated, thanks.
Here is the code for the diagnostic information. It's being run in asp.net on an aspx page.
Current Date Time: <%= DateTime.Now.ToString() %>
Current Short Date: <%= DateTime.Now.ToShortDateString() %>
Current Culture: <%= System.Threading.Thread.CurrentThread.CurrentCulture.ToString() %>
Current UI Culture: <%= System.Threading.Thread.CurrentUICulture.ToString() %>
DateTimeFormatInfo invariant = CultureInfo.InvariantCulture.DateTimeForamat;
DateTimeFormatInfo uiThread = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat;
DateTimeFormatInfo thread = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat;
Type type = System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.GetType();
foreach( var prop in type.GetProperties()) {
<%= prop.Name %>
<%= prop.GetValue(invariant, null) %> <br/>
<%= prop.GetValue(uiThread, null) %> <br/>
<%= prop.GetValue(thread, null) %> <br/>
}
Region & Language Settings
Here is some additional information
Each user has different region profile. Your current account and application may not using same account that why you see the different value.
Go to Region settings windows -> Administrative -> Click on Copy Settings and tick all check box (Welcome screen and system accounts + New user accounts) then click ok. See if it fix your problem. If your app is Web Application you need to create another AppPool to see it affected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With