在我们在Windows 10上运行的开发机器中,“fa-IR”文化工作正常,所有日期都使用波斯日历显示。但是当我们在Windows Server 2012 r2上部署我们的应用程序时,datetime仍然是Gregorian。
最有可能的是fr-IR
文化没有安装在服务器上。
为了澄清我们在Windows Server2012中使用fa-IR所遇到的问题,这里有一个在Windows 10中正常工作但在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));
Windows 10的结果(罚款):1368年2月12日,星期四 Windows 2012结果(只是波斯语字母):1990年2月1日星期四