how to Run a loop for a set amount of time

Hi, I am looking for a way to Run a loop for a set amount of time (like 1 hour)
i hear millis() is a good way to do it can anyone explain (in details and an example) please
Thanks

See Using millis() for timing. A beginners guide, Several things at the same time and the BlinkWithoutDelay example in the IDE

void loop()
{
  // variables that will be remembered
  static bool isStarted = false;
  static uint32_t startTime;

  // if not started yet
  if (isStarted== false)
  {
    // set start time
    startTime = millis();
    // indicate that we're started
    isStarted = true;
  }

  // if time lapsed
  if ((millis() - startTime) >= duration)
  {
    // nothing to do anymore, bail out
    return;
  }

  // do whatever needs to be done
  ...
  ...
}