Only print when the button is pressed and not being pressed anymore
If you want to be simple, you can use this library. The code will be

#include &lt;ezButton.h&gt;

ezButton button(7);  // create Button object that attach to pin 7;

void setup() {
  Serial.begin(9600);
  button.setDebounceTime(100); // set debounce time to 100 milliseconds
}

void loop() {
  button.loop(); // MUST call the loop() function first

  if(button.isPressed())
    Serial.println("OnsetTime");

  if(button.isReleased())
    Serial.println("GetOffsetTime");
}


If you want to understand in depth, You can see the code and instruction in this tutorial