5

In our development machine which is running on Windows 10, "fa-IR" culture works fine and all dates display using Persian calendar. But when we deploy our app on Windows Server 2012 r2, datetime is still in Gregorian.

Richard Schneider
  • 34,944
  • 9
  • 57
  • 73
moo
  • 51
  • 1
  • What do you mean "fa-IR culture works fine"? How are you using it in your application? Or is it an OS setting? – ProgrammingLlama May 20 '18 at 06:00
  • i user like this DateTime.Now.ToString("ddd, dd MMM yyyy", new System.Globalization.CultureInfo("fa-IR")). In windows 10 date time display as Persian but in server is Gregorian. – moo May 20 '18 at 06:08
  • Locale settings on both the machines are same? – Chetan May 20 '18 at 08:22
  • yes. but there is a difference between them. in the "Current system location" of windows 10 "Persian (Iran)" is available but in server "Persian" is available. I don't know if it can affect or not. – moo May 20 '18 at 08:40

3 Answers3

2

for clarification of the problem we have with fa-IR in Windows Server2012, here is an example that works fine in Windows 10 but do not work in Windows 2012:

DateTime startDate;
CultureInfo c = CultureInfo.CreateSpecificCulture("fa-IR");
DateTime.TryParse("1990/02/01", new CultureInfo("en-US"), DateTimeStyles.None, out startDate);
Console.WriteLine(startDate.ToString("D", c));

The Windows 10 result (fine): پنجشنبه, 12 بهمن 1368
The Windows 2012 result (just persian letters):پنجشنبه، 01 فوريه 1990

Ehsan Abidi
  • 911
  • 9
  • 24
0

It's most likely that the fr-IR culture is not installed on the server.

See Installing more cultures on Windows Server 2012 for more help.

Richard Schneider
  • 34,944
  • 9
  • 57
  • 73
  • Thank you. when i use this sample c# code and i want to LoadDataFromCultureInfo from "fa-IR" culture i have an error with this error message "Custom calendars are not currently supported" – moo May 20 '18 at 11:16
  • Maybe this will help https://blogs.msdn.microsoft.com/shawnste/2013/11/18/locale-builder-v2-0-for-windows-8-1server-2012-r2-released/ – Richard Schneider May 21 '18 at 09:36
0

This depends on the version of Windows, Persian calendar was added in Windows Server 2012 R2 And Windows 10.

SQL Server FORMAT with culture parameter not working

Fred
  • 3,365
  • 4
  • 36
  • 57
  • 1
    In Windows 2012 R2 when we use "fa-IR" date-time will be translated to Persian, like "پنجشنبه، 01 فوريه 1990". finally, we just upgrade windows version to 2016 and problem fixed. – moo Feb 12 '20 at 04:46