无法将字符串转换为dateTime [英] Cannot convert a string to the dateTime
问题描述
大家好,
Hi all ,
执行以下代码
On executing the below code
DateTime昨天= Convert.ToDateTime(" 02-MAR-18 10:44:44 AM");
var dateTime = DateTime.ParseExact(yesterday.ToString()," dd-MMM-yy hh:mm:ss tt",CultureInfo.InvariantCulture);
DateTime yesterday = Convert.ToDateTime("02-MAR-18 10:44:44 AM");
var dateTime = DateTime.ParseExact(yesterday.ToString(),"dd-MMM-yy hh:mm:ss tt",CultureInfo.InvariantCulture);
我得到的错误就像字符串不是有效的格式转换为DateTime。
I get the error like the string is not in the valid format to convert to DateTime .
如果有人可以向我推荐一些想法,那将会非常有用通过这个。
Would be really helpful if anyone could suggest me some ideas to get through this .
提前致谢
Thanks in advance
sauthee
推荐答案
您好,
尝试
DateTime.Parse()
DateTime.Parse()
DateTime.ParseExact()
DateTime.ParseExact()
这篇关于无法将字符串转换为dateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!