Answers for "check current time between two times in c#"

C#
1

check if current time is in the morning c#

TimeSpan time = DateTime.Now.TimeOfDay;

if (time > new TimeSpan(00, 00, 01)        //Hours, Minutes, Seconds
 && time < new TimeSpan(08, 00, 00)) {
    //match found
}
Posted by: Guest on June-22-2020
0

how to check if time is between two timespans in c#

if (interval.StartTime < interval.EndTime)
{
    // Normal case, e.g. 8am-2pm
    return interval.StartTime <= candidateTime && candidateTime < interval.EndTime;
}
else
{
    // Reverse case, e.g. 10pm-2am
    return interval.StartTime <= candidateTime || candidateTime < interval.EndTime;
}
Posted by: Guest on December-01-2020

Code answers related to "check current time between two times in c#"

C# Answers by Framework

Browse Popular Code Answers by Language