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

C#
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 "how to check if time is between two timespans in c#"

C# Answers by Framework

Browse Popular Code Answers by Language