C# Compare Time between Two Time Intervals

后端 未结 6 967
暖寄归人
暖寄归人 2020-12-19 18:59

Trying to compare a given Time between two times to see if it\'s within the those intervals. e.g. if given Time is 00:00 I need to find out if it falls between 21:00:00 to

6条回答
  •  北海茫月
    2020-12-19 19:10

    Not sure why timespan is not working for you.

    I tried this sample in my POC application and it worked.

     DateTime t1 = DateTime.Now;
        DateTime t2 = DateTime.UtcNow;
        t1.TimeOfDay.CompareTo(t2.TimeOfDay);
    

    Try this hope it will solve the problem.

提交回复
热议问题