Millis, timer with function running during set time

Fixed

Have a look at [url=http://Using millis() for timing. A beginners guide]Using millis() for timing. A beginners guide[/url]

Fixed

Here is an example of what I think you are trying to do.

unsigned long currentTime;
unsigned long shortPeriodStartTime;
unsigned long longPeriodStartTime;
unsigned long longPeriod = 30000;  //30 seconds 
unsigned long shortPeriod = 5000;  //5 seconds
boolean longTimerRunning = true;

void setup()
{
  Serial.begin(115200);
  shortPeriodStartTime = millis();
  longPeriodStartTime = shortPeriodStartTime;
  Serial.println("Long and short period timing started");
}

void loop()
{
  currentTime = millis();
  //check long period
  if (currentTime - longPeriodStartTime >= longPeriod && longTimerRunning)  //long period finished
  {
    longTimerRunning = false;  //turn off the flag
    Serial.println("Long period ended");
    Serial.println("Short period timing stopped");    
  }
  
  //check sort period
  if (longTimerRunning)  //only do this while the long period is current
  {
    if (currentTime - shortPeriodStartTime > shortPeriod)  //end of a short period
    {
      Serial.println("Short period ended");
      shortPeriodStartTime = currentTime;
    }
  }
}

Please feel free to use any/all of the ideas that it uses