System.DateTime
// convert everything to TimeSpan TimeSpan start = new TimeSpan(22, 0, 0); TimeSpan end = new TimeSpan(07, 0, 0); TimeSpan now = DateTime.Now.TimeOfDay; // see if start comes before end if (start < end) return start <= now && now <= end; // start is after end, so do the inverse comparison return !(end <= now && now <= start);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)