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?
The system bases system time on coordinated universal time (UTC). UTC-based time is loosely defined as the current date and time of day in Greenwich, England.
The ISO 8601 format YYYY-MM-DD (2022-11-01) is intended to harmonize these formats and ensure accuracy in all situations. Many countries have adopted it as their sole official date format, though even in these areas writers may adopt abbreviated formats that are no longer recommended.
YYYY-MM-DD where YYYY is the year in the usual Gregorian calendar, MM is the month of the year between 01 (January) and 12 (December), and DD is the day of the month between 01 and 31.
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 :(
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