state change with timer

I want to use a momentary pushbutton to trigger a timer that will engage a relay for a specified amount of time. However, if the button is pressed again, I want to instantly turn off the relay. In addition, I want an RGB LED to change color if the relay is on or off. Here is what I have so far based on the state change example code on the arduino site. This allows me to toggle the relay and LED color back and forth without having the timer functionality implemented, yet. I have tried adding the millis() function into it with no luck. I have looked at several implementations on the web that try to do similar things, but not exactly what I am looking for.

The reason I have initialized the button at 1 is so it doesn't start in the on state when the arduino is plugged in.

Also my LED is common anode hence the inversion of values, not that it really matters in the scope of this question.

//button initialization
const int buttonPin = 2;
int buttonState = 1;
int buttonPushCounter = 1;
int lastButtonState = 1;

//relay initialization
const int relayPin = 7;

//LED initialization
const int redPin = 3;
const int greenPin = 5;
const int bluePin = 6;

//RGB 0-255 values - Pushbutton Unpressed & Timer Ready
const int redValue1 = 175;
const int greenValue1 = 0;
const int blueValue1 = 255;

//RGB 0-255 values - Pushbutton Pressed & Timer Engaged
const int redValue2 = 0;
const int greenValue2 = 0;
const int blueValue2 = 255;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(relayPin, OUTPUT);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
}

void loop() {
  buttonState = digitalRead(buttonPin);
  if (buttonState != lastButtonState) {
    if (buttonState == LOW) {
      buttonPushCounter++;
    }
  }
  delay(50);
  lastButtonState = buttonState;

  if (buttonPushCounter % 2 == 0) {
    analogWrite(redPin, 255 - redValue2);
    analogWrite(greenPin, 255 - greenValue2);
    analogWrite(bluePin, 255 - blueValue2);
    digitalWrite(relayPin, HIGH);
  }
} else {
  analogWrite(redPin, 255 - redValue1);
  analogWrite(greenPin, 255 - greenValue1);
  analogWrite(bluePin, 255 - blueValue1);
  digitalWrite(relayPin, LOW);
}
}

Forget about connecting the timer to the relay for now. Can you just get a timer to run and stop under control of buttonPushCounter?

Try this code:

uint32_t nTimerMillis = 0;

void loop() 
{
  if ((nTimerMillis == 0) && (digitalRead(buttonPin) == HIGH)) 
  {
    // Turn on the timer
    nTimerMillis = millis() + 100;

    // Turn on the relay
    digitalWrite(relayPin, HIGH);

    // Turn on LED
  }
  else if (nTimerMillis >= millis())
  {
    // Turn off the timer
    nTimerMillis = 0;

    // Turn off the relay
    digitalWrite(relayPin, HIGH);

    // Turn off LED
  }
}