C# 比较时间问题

C#中 DateTime类型的变量格式是:2015/12/11 13:58:59

如果只比较年月日而不比较时分秒,可以:

nowTime = Convert.ToDateTime(nowTime.ToShortDateString());
startTime = Convert.ToDateTime(startTime.ToShortDateString());
endTime = Convert.ToDateTime(endTime.ToShortDateString());

这样会把时分秒全部置为0,如:2015/12/11 0:00:00

原文地址:https://www.cnblogs.com/Anthony-Wang/p/5038966.html