我正在尝试解析以下英国格式的DateTime
字符串:24/01/2013 22:00
但是,我一直收到以下错误:
字符串无法被识别为有效的 DateTime。
CultureInfo.CurrentCulture
返回了"en-GB
",这是正确的
以下是我的代码
[TestMethod]
public void TestDateTimeParse()
{
DateTime tester = DateTime.ParseExact("24/01/2013 22:00", "d/M/yyyy hh:mm", CultureInfo.CurrentCulture);
int hours = tester.Hour;
int minutes = tester.Minute;
Assert.IsTrue(true);
}
ParseExact
时,文化背景会有太大的影响。 - Rudi Visser