我想将日期“01/22/2013 10:00:00”转换为“22/01/2013 10:00:00”,并且我的方法无法识别我的日期字符串。将日期时间转换为英国格式
DateTime dt = DateTime.ParseExact(StartDate, "MM dd yyyy h:mm", CultureInfo.InvariantCulture);
StartDate = dt.ToString("dd/M/yyyy");
dt = DateTime.ParseExact(EndDate, "MMM dd yyyy h:mm", CultureInfo.InvariantCulture);
EndDate = dt.ToString("dd/M/yyyy");
我收到此错误:
System.FormatException - String was not recognized as a valid DateTime.
什么是ParseExact正确的字符串格式?
可以很容易地看出,该字符串应该是'MM/DD/YYYY HH:MM:ss'即使不看文档。 – Jon