Why is the date format different for the same culture on different computers or OS?

I have a problem with the date format while hosting a site that was developed using C # .net MVC.

In my development machine ( OS: Windows 7, .net Framework 4.5 ), the date format for the spanish panama (es-PA) is mm / dd / yy and on the server machine ( OS: Windows 8, .net Framework 4.5 ) it provides the format d / m / yy for the same culture.

I tested it with a simple console application.

public static void Main() { DateTime dt = DateTime.Now; Thread.CurrentThread.CurrentCulture = new CultureInfo("es-PA"); Console.WriteLine(dt.ToString("d")); Console.ReadLine(); } 

Exit on the development machine: 08/10/2015

Output on the server machine: 8/10/15

I also checked by changing the Language and Regional, but in both formats the machines are different by default.

Why is the format different on different machines for the same culture? Is there any solution for this?

+7
c # windows date-format cultureinfo
source share
2 answers

Why is the format different on different machines for the same culture?

Since the formats are updated over time, in different OS releases and in patches / patches..NET extracts the format from the OS (I think, anyway), so the OS is the source of the difference - as you saw in the regional settings.

Is there any solution for this?

Verify that both computers are updated using Windows Update, and perhaps check for available fixes. Otherwise, you can always manually update the one you want to change, but obviously this is far from ideal.

It is possible that Windows 8 simply has more up-to-date information than Windows 7, so that it will not be fixed when updating Windows: (

+3
source share

Cultures have several accepted formats. A thread receives its culture (and therefore format) from the account that the thread executes.

For example, if you use IIS express on your dev machine (IIS express uses a Windows user account for the ASP.NET workflow), you can switch to another valid format for the same culture in windows, and now it will be the output format for your web applications.

It is difficult to give a solution to the problem. This is still the same date and actually displays the established culture properly.

However, if you want to format the format, you must do this by setting, for example, CurrentCulture.DateTimeFormat.ShortDatePattern

-one
source share

All Articles