How to get a servo motor to run for 30mins then stop

Hi i am new to arduino boards and just wonder could anyone help me figure out how to get a sevo motor to run for 30mins and then stop. i have been looking at tutorials for the last couple of day and still have no joy. i have copied my program below it currently has a counter and it runs fine its just i want to swap out the counter with some sort of timer to make it run for 30 mins. Thank you

#include <Servo.h>

Servo myservo;

int pos = 0;
int myCounter = 0;
int mySwitchPin = 4;

void setup() {
myservo.attach(9);
pinMode(mySwitchPin, INPUT_PULLUP);
}

void loop() {

if(myCounter<10)
{
for (pos = 35; pos <= 155; pos += 1)
{
myservo.write(pos);
delay(15);
}
for (pos = 155; pos >= 35; pos -= 1)
{
myservo.write(pos);
delay(15);

}
myCounter = myCounter + 1;
}
else if(digitalRead(mySwitchPin) == LOW)
{
myCounter = 0;
}
}

Like this:

#include <Servo.h>

Servo myservo;

void setup() {
  myservo.attach(9);
}

void loop() {
  if (millis() < 30UL*60UL*1000UL) {
    for (int pos = 35; pos <= 155; pos += 1) {
      myservo.write(pos);
      delay(15);
    }
    for (int pos = 155; pos >= 35; pos -= 1) {
      myservo.write(pos);
      delay(15);
    }
  }
}

Thank you ill give that a go today

Cross-post. Thread locked.

DO NOT CROSS-POST, CROSS-POSTING WASTES TIME.