Relay off/on without using delay?

I know I should probably understand more then I do before I even ask, but just in case there is someone out there that is interested.

I am trying to turn my relay switch off and on at set times like 8AM to 9PM but im not sure how to even go about doing that, ive seen some tutorials for clocks etc, but I havnt found one that works for me yet... Maybe im getting in over my head but any help would be appreciated... All I understand how to use is delay but thats not doing what I want it to do.

Forgive me for my newbness...

int relay1 = 1;
int relay2 = 2;
int relay3 = 3;
int relay4 = 4;
  
void setup()
{
  pinMode(1, OUTPUT);         //Set Pin1 as output
  digitalWrite(1, HIGH);      //Set Pin1 High, keeps off relay until low signal recieved
  pinMode(2, OUTPUT);         //Set Pin2 as output
  digitalWrite(2, HIGH);      //Set Pin2 High, keeps off relay until low signal recieved
  pinMode(3, OUTPUT);         //Set Pin3 as output
  digitalWrite(3, HIGH);      //Set Pin3 High, keeps off relay until low signal recieved
  pinMode(4, OUTPUT);         //Set Pin4 as output
  digitalWrite(4, HIGH);      //Set Pin4 High, keeps off relay until low signal recieved
}
void loop()
{

          digitalWrite(relay1, HIGH);   //Turn off relay
          delay(2000);
          digitalWrite(relay1, LOW);    //Turn on relay
          delay(2000);
}

I am trying to automate my aquariums lighting in case anyone is wondering what this is for...

Anyways thanks for reading...

For that kind of delay you really need a real-time clock module like the DS1306 or DS1307.

ty for the quick reply, wow looks like im going to have to to some reading, now I know where to look though. if I had the ethernet shield couldn't I just use ntp to do the same thing?

Fleshwound: ty for the quick reply, wow looks like im going to have to to some reading, now I know where to look though. if I had the ethernet shield couldn't I just use ntp to do the same thing?

Yes. With an Ethernet shield, you could send out a request for the time every say 10 seconds, and use that to determine if the relay needs to be on or off. If you're contemplating getting one just for that purpose, that's would be a pretty expensive option. If you're getting one anyway, then that's a fine way to do it.