>Hi,
>
>When I use the following function to get the time of the day:
>
>tsTime1 = new TimeSpan(24, 0, 0);
>// tsTime1 is 1:00:00:00. And I thought it should be 24:00:00
>
>
>When I use the following time of the day:
>
>tsTime2 = new TimeSpan(24, 60, 0);
>// txTime2 is 1:01:00:00
>
>
>How do I get the time of exactly 24:00:00? So that when I compare it with DateTime.Now.TimeOfDay I have the correct result.
>
>TIA
>
>Update: I found this thread:
>
https://stackoverflow.com/questions/246225/best-way-to-create-a-midnight-datetime-in-c-sharp>
>which shows that midnight time is "00:00:00"
>
>What puzzles me is how do you compare is the current time (defined by an hour and minutes, e.g. 24, 00) compares to this time? That is, is now before the midnight or after?
You can add a timespan to a date to check.
var tsTime1 = new TimeSpan(24, 0, 0);
var dt = DateTime.Today + tsTime1; // 12/21/2018 00:00:00
Console.WriteLine(dt);
Console.WriteLine ( $"{dt} is later than now {dt > DateTime.Now}");