"Sleep"mode in code

Hi,
I'm trying to do something pretty simple, but having a little trouble finding the correct way to code it.
I'm a bit of a beginner, so bare with me.
I have two outputs (motors) that I switch between, using a momentary button.
I'd like to have the following feature added if possible:
If the momentary switch has not been pressed (to toggle between outputs) in over 10 minuets, have both outputs turn off. (hence "sleep" mode)
When the button is finally pressed, it will "wake up" and resume normal operation.
Here's what I have so far, It works fine except I don't know how to do proposed "sleep" portion in code.
Any help would be greatly appreciated. Thanks.

// constants won't change. They're used here to set pin numbers:
const int button = 2;    // the input pin number of the pushbutton
const int motorApin = 12;      // the pin number for motor "A"
const int motorBpin = 13;      // the pin number for motor "B"

// Variables will change:
int MotorState1 = LOW;          // the current state of the motor output pin
int MotorState2 = HIGH;         // the current state of the motor output pin
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin

// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
unsigned long debounceDelay = 50;    // the debounce time; increase if the output flickers

void setup() {
 pinMode(button, INPUT);
 pinMode(motorApin, OUTPUT);
 pinMode(motorBpin, OUTPUT);

 // set initial LED state
 digitalWrite(motorApin, MotorState1);
 digitalWrite(motorBpin, MotorState1);
}

void loop() {
 // read the state of the switch into a local variable:
 int reading = digitalRead(button);

 // check to see if you just pressed the button
 // (i.e. the input went from LOW to HIGH), and you've waited long enough
 // since the last press to ignore any noise:

 // If the switch changed, due to noise or pressing:
 if (reading != lastButtonState) {
   // reset the debouncing timer
   lastDebounceTime = millis();
 }

 if ((millis() - lastDebounceTime) > debounceDelay) {
   // whatever the reading is at, it's been there for longer than the debounce
   // delay, so take it as the actual current state:

   // if the button state has changed:
   if (reading != buttonState) {
     buttonState = reading;

     // only toggle the LED if the new button state is HIGH
     if (buttonState == HIGH) {
       MotorState1 = !MotorState1;
       MotorState2 = !MotorState2;
     }
   }
 }

 // set the LED:
 digitalWrite(motorApin, MotorState2);
 digitalWrite(motorBpin, MotorState1);

 // save the reading. Next time through the loop, it'll be the lastButtonState:
 lastButtonState = reading;
}

If the momentary switch has not been pressed (to toggle between outputs) in over 10 minuets, have both outputs turn off. (hence "sleep" mode)

so in the loop you should capture the time (using millis() ) when there is a press and outside all other considerations, do another test to see if 10 minutes have elapsed. if so go to a stage where you do an active wait (if your code has nothing else to do) on the button press

what should happen if I press the button but do not release for 15 minutes?


Please correct your post above and add code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

Thanks for the reply.
So, I'm still not sure how to effective use this command.
Forgetting my specific application, if I want to keep track of time passed within a loop, but then do something when the specified time has passed, what else would I need, and where would it go?
Would I have a secondary loop that it would jump to and wait until the button is pressed, then jump back?
How exactly would I do this?

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
millis(600000) //10 minute 
}

assuming some kind of event becomes true to trigger when you start counting, something like this would probably work (typed here, so may be some typos)

void loop()
{
  static unsigned long startTime; 
  static bool clockIsTicking = false;

  if ( (! clockIsTicking) && (some kind of event triggering the clock is true) ) {
    clockIsTicking = true;
    startTime = millis();
  } 

  if (clockIsTicking && (millis() - startTime >= 60000UL) {
    // time is up !
    clockIsTicking = false;
    Serial.println(F("Time's up!!"));
  } 

  // here you can do something else and you can check clockIsTicking if you don't want to do anything
  // when the clock is ticking for example
  ...

}