I have problem with date formate while hosting site which is developed using C# .net MVC .
In my development machine(OS:Windows 7, .net Framework 4.5) date formate for Spanish-Panama(es-PA) is mm/dd/yy and in server machine(OS:Windows 8, .net Framework 4.5) it is giving d/m/yy format for same culture.
I checked it with by using 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();
}
Output on development machine is: 10/08/2015
Output on server machine is : 8/10/15
I also checked by changing Language and Regional but in both machine default format is different.
Why format is different in different machine for same culture? Is there any solution for this?
Why format is different in different machine for same culture?
Because formats are updated over time, in different OS releases and in patches/hotfixes. .NET is fetching the format from the OS (I believe, anyway), so it's the OS that's the source of the difference - as you've seen in the regional settings.
Is there any solution for this?
Check that both machines are up to date with Windows Update, and possibly check for any hotfixes available for this. Otherwise, you could always manually update the one you want to change, but obviously that's far from ideal.
It's possible that Windows 8 just has more up-to-date information than Windows 7 in a way that isn't going to be addressed by Windows update :(
See more on this question at Stackoverflow