时间操作

 

//将202004这样的格式转换为时间格式

DateTime date = DateTime.ParseExact(datetime, "yyyyMM", System.Globalization.CultureInfo.CurrentCulture);

//本月天数

int days = DateTime.DaysInMonth(date.Year, date.Month);
//本月第一天
DateTime beginTime = date.AddDays(1 - (date.Day));

//本月最后一天
DateTime endTime = beginTime.AddDays(days - 1);
List<NumData> dateList = new List<NumData>();
for (DateTime dt = beginTime; dt <= endTime; dt = dt.AddDays(1))
{
dateList.Add(new NumData { time=dt.Date, Score=null});
}

 

posted @ 2020-06-09 14:12  噜啦啦0001  阅读(148)  评论(0编辑  收藏  举报