How to make distance sensor print just one value

My project seems pretty simple, but I'm extremely new to programming so it's proving to be tough! My setup is a distance sensor and a button. When someone comes in range of the distance sensor, I have the time (in ms) print to the serial monitor. The same thing occurs with the button. My issue is that the distance is constantly sensing, so it prints a massive amount of numbers in a short period of time. So, is there a way to have the distance sensor print just one number, even if it continues to detect the persons standing in front of it? Thank you for any advice!

const int button1Pin = 2;
const int ledPin = 13;

int distanceSensor; //distance values are 0 to 1023
int button1State;
unsigned long currentTime;

void setup() {

  pinMode(button1Pin, INPUT);
  pinMode(ledPin,OUTPUT);
  Serial.begin(9600);
}

void loop() {
  button1State = digitalRead(button1Pin);
  distanceSensor = analogRead(2);
  if (distanceSensor > 200){
    digitalWrite(ledPin, HIGH);
  
    currentTime = millis(); //milliseconds
    if (button1State == LOW){
      Serial.println(currentTime);
      delay(1000);
      //if (button1State == LOW){
      //  digitalWrite(resetpin, LOW);
      //}
    }
  }else{
    
    digitalWrite(ledPin, LOW);
  }

}
[code]
When someone comes in range of the distance sensor, I have the time (in ms) print to the serial monitor.

No, you don't. When someone IS in range, not when someone BECOMES in range, you print the time, IF the switch state is LOW.

You need to look at the state change detection example. While it is written for digital inputs, the same logic applies to the current value being above the threshold and the previous value was below the threshold or the current value is below the threshold but the previous value was above the threshold.

Why printing the time depends on the state of the switch is a mystery.