Sure you can. Use delay if there is absolutely nothing else (like a manual turn on or off or abort) that has to happen during the delay time. The delay() function completely blocks execution (except interrupts). Avoid interrupts until you have some experience.
Or use millis() to do the timing. Other things, like a manual turn on or off or abort, can be sensed while executing a millis() delay.
Non-blocking timing tutorials:
Blink without delay().
Beginner's guide to millis().
Several things at a time.
But, like I said, the timing will not be very accurate and will drift. If what you want to happen at 5 PM one day might drift so that it happens at 6 PM a few days later.