要检查一天中的时间,请使用:
TimeSpan start = new TimeSpan(10, 0, 0); //10 o'clockTimeSpan end = new TimeSpan(12, 0, 0); //12 o'clockTimeSpan now = DateTime.Now.TimeOfDay;if ((now > start) && (now < end)){ //match found}
对于绝对时间,请使用:
DateTime start = new DateTime(2009, 12, 9, 10, 0, 0)); //10 o'clockDateTime end = new DateTime(2009, 12, 10, 12, 0, 0)); //12 o'clockDateTime now = DateTime.Now;if ((now > start) && (now < end)){ //match found}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)