这边用的是转换的方式去做的,我就是做个学习记录。
string dataStr = "06:00-22:00";
DateTime datetimeNow = DateTime.Now;
var dateTime1 = new DateTime(
datetimeNow.Year,
datetimeNow.Month,
datetimeNow.Day,
int.Parse(dataStr.Split('-')[0].Split(':')[0]),
int.Parse(dataStr.Split('-')[0].Split(':')[1]), 0);
var dateTime2 = new DateTime(
datetimeNow.Year,
datetimeNow.Month,
datetimeNow.Day,
int.Parse(dataStr.Split('-')[1].Split(':')[0]),
int.Parse(dataStr.Split('-')[1].Split(':')[1]), 0);
欢迎进qq群交流:704028989