Simple way to handle time in C#?

前端 未结 4 1496
囚心锁ツ
囚心锁ツ 2020-12-18 08:01

My current approach is something like

DateTime startHour = new DateTime(1900,1,1,12,25,43);
DateTime endHour = new DateTime(1900,1,1,13,45,32);

// I need to         


        
4条回答
  •  一整个雨季
    2020-12-18 08:16

    So you're only interested in the time component of the date.

    if(DateTime.Now.TimeOfDay > startHour.TimeOfDay)
    {
      // do stuff
    }
    

    What's wrong with doing this?

提交回复
热议问题