0
我有来自RSS提要的值Thu, 06 Nov 2014 10:47:21 GMT
。我想将此字符串保存到MS SQL数据库中的DateTime字段。但是,我得到一个错误将字符串从RSS提要转换为数据库的DateTime
“字符串未被识别为有效的DateTime”
DateTime date = Convert.ToDateTime(a.PubDate);
string dateString = a.PubDate;
DateTime convertedDate = DateTime.ParseExact(dateString, "ddd dd MMM yyyy hh:mm:ss ttt", System.Globalization.CultureInfo.InvariantCulture);
db.Entry(a).State = System.Data.Entity.EntityState.Modified;
db.SaveChanges();