这是我的代码:
DateTime Now = DateTime.Parse(DateTime.Now.ToString(), new System.Globalization.CultureInfo("fa-ir"));
Geogorian 日期是:16/06/2016
波斯日期是:15/03/1395
而 Now 的值为:07/09/2025
时间是正确的。 可能是什么问题?
最佳答案
您只是将 cultureinfo 参数传递给 Parse,而不是 ToString。这意味着字符串使用 thread 文化进行格式化,然后使用 fa-ir 文化进行解析。
关于c# - 使用 CultureInfo 时 DateTime.Parse 返回错误值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37630863/