转载:原文链接:https://blog.csdn.net/Helloantoherday/article/details/108016638
*第一种方法**
string timeStr = "2019-08-28";
DateTime time= Convert.ToDateTime(timeStr);
**第二种:**
DateTimeFormatInfo timeForInfo = new DateTimeFormatInfo();
timeForInfo.ShortDatePattern = "yyyy/MM/dd";
string timeStr1 = "2018-09-08";
var time = Convert.ToDateTime(timeStr1, timeForInfo);
**第三种:**
string dateString = "20190526";
DateTime time = DateTime.ParseExact(dateString, "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture);
————————————————
版权声明:本文为CSDN博主「行者僧」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Helloantoherday/article/details/108016638