Arduino going into sleep mode after 45s when there hasnt been interaction

Hi,
Im building a project that needs to be energy efficient since it runs on batteries.
I need a timer to start and count up to 45 seconds that will put the arduino in sleepmode using a CTC interrupt.
When there is interaction during the time counting up to 45 seconds it needs to reset the timer to zero. My problem is that I don't know how to start and stop a timer. I have only worked with timers that are constantly on.
After it goes back to sleep mode the timer will be disabled and I need to turn it back on as soon as an external interrupt wakes up the arduino.

Can you tell me how to stop and start a timer?

Thank you in advance

I need a timer to start

No, you don't.

You need to pay attention to when the Arduino was interacted with - the event of interest.

Periodically (on every pass through loop()), you see how long ago the event of interest occurred. If happened long enough ago, put the Arduino to sleep.

unsigned long last_interaction = 0L ;


void loop ()
{
  ...
  ...

  if (millis () - last_interaction >= 45000L)
  {
    enter_sleepmode () ;  // assumption this only returns when sleep is cancelled.
    last_interaction = millis () ; // reset timestamp to prevent immediate re-sleep
  }
  ...
}

Add "last_interaction = millis() ;" for every interaction too. Note that after
coming out of sleep-mode itself should count as an interaction or the test
for going to sleep will re-trigger.