Find time value between two other time values? C#

Hi all,

Anyone know how to do this in a basic ‘Hello World’ style?

I’m learning C# and am wanting to basically convert my JS over to C#.

How would i check if todays time is within two set times? Example todays time is 13.30.00 and I’m wanting to check if it is between 10.00.00 and 18.00.00?

Any help would be muchly appreciated!

Try converting your time to seconds and compare to the other values in seconds.

13.30.00 = 48600
//currentTime = 48600

10.00.00 = 36000
//lowTime = 36000

18.00.00 = 64800
//highTime = 64800

if(currentTime <= highTime && currentTime >= lowTime){
//the time is between 10 and 18
}

if the current time is less than or equal to high time AND the current time is greater than or equal to the low time, the current time is between the high and low time

I’m back again,

I’m having trouble getting it to read as an int and not a string:

private int currentHour = System.DateTime.Now.ToString("hh");

Ive tried a couple of things but can’t work it out.

Any ideas?

Thanks again