delay(); more

Hello, my query is as follows, I am new to the topic, I am doing a cycler, I need to enable an output in long cycles, some of 20 minutes and others up to 8 hours, until now I used the delay () function; It is in milli-seconds, but now as the wait is several minutes and even hours, is it convenient to use this function or what can I do?
Example of what I need to do, turn on a lamp for 8 hours, then it stays on for 8 hours and turns off for 8 hours ... and so on.
I have an Arduino Mega board and an Arduino nano
Thank you.

Google: Arduino Blink Without Delay BWD


Hint eight hours 8 * 60 * 60 * 1000ul ms

millis() returns ‘unsigned long’

unsigned long (32 bit) - unsigned number from 0-4,294,967,295

You can use delay(), I would rather suggest you to use millis() instead, so you dont block the CPU and if needed do something else (for example, if you try to command two lamps)

So basicly, you have a variable for interval in ms (10006060*hours needed).
Another variable for "when last time commanded", which keeps the millis() of last time something happened.
Then you query in your loop millis() - lastTimeMillis > interval
If yes, change lamps state.

Here is an example code: