字符串日期时间:无法识别为有效的DateTime [英] String to datetime: not recognized as a valid DateTime
本文介绍了字符串日期时间:无法识别为有效的DateTime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好了,所以经过一番研究,我没有找到任何办法来解决我的问题。
Ok so after some research I haven't found any way to solve my problem .
这是我的字符串到日期的转换code:
This is my String to Date conversion code:
DateTime startDate = new DateTime();
startDate = DateTime.ParseExact(this.items[5], "dd/MM/yyyy HH:mm:ss",
CultureInfo.InvariantCulture);
这是我要转换的字符串:
And this is the string I want to convert:
"22/2/2013 09:57:32"
但是,当我编译我有这样的错误:
But when I compile I have this error:
字符串未被识别为有效的DateTime。
String was not recognized as a valid DateTime.
我应该怎么办?
推荐答案
您的模式应该是DD / M / YYYY HH:MM:SS
MM
要求0领先,这是不提供你的输入字符串。
MM
requires leading 0, which is not provided in your input string.
这篇关于字符串日期时间:无法识别为有效的DateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文