Get how many hours, minutes and seconds until midnight in c#

Viewed 694

I want to get how many hours, minutes and seconds until Midnight. I have the following code:

    _midnight = DateTime.Today; // this is th midnight
    Debug.Log("current " + DateTime.Now);
    Debug.Log("TimeToMidnight " + _midnight.Subtract(DateTime.Now));

This how I get as a Debug message:

  • current 9/8/2020 3:09:41 PM
  • TimeToMidnight -15:09:41.5144330

As you can see, the time to Midnight is completely wrong. I'm I missing something?

0 Answers
Related