Date 日期时间格式全球化更改

Date 日期时间格式全球化更改,date,date-parsing,Date,Date Parsing,我想将不同的日期格式转换为当前日期格式 例如: Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("tr-TR"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("tr-TR"); string dateString = "16.03.2020 10:50:00"; //(I record the value) (now format

我想将不同的日期格式转换为当前日期格式

例如:

Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("tr-TR");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("tr-TR");
string dateString = "16.03.2020 10:50:00"; //(I record the value) (now format dd.MM.yyyy HH:mm:ss)

//Change Culture (en-US)
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

Datetime convertedDate = Convert.ToDatetime(dateString); //(now format dd/MM/yyyy HH:mm:ss)
错误=字符串未被识别为有效的日期时间

我怎么解决呢?

我是这样解决的

string dateString = "16.03.2020 10:55:10"; //Çağdaş SANCARBARLAZ
DateTime lastCheckDate = Convert.ToDateTime(dateString,
System.Globalization.CultureInfo.GetCultureInfo("tr-TR").DateTimeFormat);
结果:


谢谢大家

查阅
DateTimeFormatterBuilder
LocalDateTime的文档。请在应用程序中使用ISO格式,以便人们能够轻松理解日期。这是什么语言?是C#还是另一种基于.net的语言?请相应地标记您的问题,因为这里会询问有关数百种og编程语言的问题。这也将有助于吸引那些知道的人。并在文本和/或标题中提及语言。非常感谢。由于需要澄清,我已投票决定结束投票,并将很高兴在您编辑后删除我的结束投票。