how registers number in between

hey guys I am not aware of my headline makes sense? What I can not figure out is. I need to turn my light in my display between the hours of 17 to 23. After 23 o'clock must be off again. How to write it in code. I turn it at 18, and it works, but it should go off again after 23 pm? So between 18 and 23 must be turned on. I've tried searching but I do not know how to formulate my questions?

Thanks, Thoger DK.

if ((time > 17) && (time <23))

KeithRB:
if ((time > 17) && (time <23))

Assuming that time means hour…

Or something like:

if(hour >= 17 && !lighOn){
  //turn light on
}
else if (hour >= 23 && lightOn){
  //turn light off
}

It works, Thanks :-)