C#时间与String转换

//将含有正确日期格式的string类型转换成DateTime类型
string strDate = "2014-08-01";
DateTime dt1 = Convert.ToDateTime(strDate);
//将包含时分秒的string类型日期转换成DateTime类型
string strDateTime = "2014-08-01 10:57:31";
DateTime dt2 = Convert.ToDateTime(strDateTime);

posted @ 2020-09-03 11:32  搬砖的L先生  阅读(440)  评论(0)    收藏  举报