I've set, in my regional settings (for Czech, culture cs-CZ), the short time / long time pattern to following:
I'm trying to use those settings in C# applications. In following console app, everything works:
using System; using System.Globalization;
class Program
{
static void Main()
{
Console.WriteLine(CultureInfo.CurrentCulture.Name);
Console.WriteLine(CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern);
Console.ReadLine();
}
}
The output is, as I thought, following:
cs-CZ
H.mm.ss
I've created ASP.NET application, which, to my uttermost surprise, doesn't reflect this.
Minimal example:
<%@ Page Language="C#" %>
<%= System.Globalization.CultureInfo.CurrentCulture.Name %><br />
<%= System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern %>
Output:
cs-CZ
H:mm:ss
I've tried restarting, .NET2.0, .NET4.0, still no effect.
Note - This issue raised as a part of bug, where we forgot to include InvariantCulture for DateTime.ToString(), which should then be parsed by JSON deserializer. (The guy with this problem has somewhat different Time format separator).
Fixing the issue with re-creating CultureInfo isn't something I'm looking for, I just want to see the reason, as I wasn't able to reproduce the issue with any means.
The problem is that the Regional Settings are user specific. You changed them for you, but the site runs as a different user (see the app-pool in IIS)
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