Convert.DateTime throws error: String was not recognized as a valid DateTime for “06-13-2012”

前端 未结 5 1938
小鲜肉
小鲜肉 2020-12-18 04:21

I am inserting a date into my database, the value which comes from:

s.theDate = Convert.ToDateTime(\"06-13-2012\");

and I get the error, \"

5条回答
  •  情歌与酒
    2020-12-18 04:54

    There is a global standard called ISO 8601 that you may (imo should) use. Using this standard, this is what you will end up with.

    Convert.ToDateTime("2012-06-03");
    

提交回复
热议问题