how to write "if value is true for a set amount of time"

I think I would do this "the other way around" - by resetting the timer every time the button is unpressed

void loop() {
   buttonState = digitalRead(buttonPin);
   if (buttonState == HIGH) {
      startTime = millis();
   }
   if (millis() - startTime >= interval) {
      // do whatever
   }
}

...R