Find the time between HIGH state & LOW state of push button(switch).

I want to find the timing between HIGH state and LOW state of push button. For that, I made a program. You can see my program below. In my program, I made logic like that when switch is pressed then one variable "currentMillis" store the value of millis() and it store value until button pressed. But whenever I pressed button again then it also add previous value. For example, if button pressed for first time then suppose we got 200ms, now suppose if button pressed second time then we got 500ms and if button pressed third time then we got 1000ms. That mean every time value added. No doubt I made a logic which seem to be perfect but I can't figure out what is problem. Please give me some suggestions.

const int  buttonPin = 2;   

unsigned long currentMillis = 0; 
unsigned long previousMillis = 0;
unsigned long finalMillis = 0;

int buttonPushCounter = 0;

void setup() 
{
  Serial.begin(9600);
  
  pinMode(buttonPin, INPUT);
  digitalWrite(buttonPin, HIGH);
}

void loop() 
{
  if (digitalRead(buttonPin) == LOW)
  {
     buttonPushCounter++;
     Serial.println("on");
     Serial.print("number of button pushes:  ");
     Serial.println(buttonPushCounter);

     while(digitalRead(buttonPin) == LOW)
     {
        currentMillis = millis();
     }
      
      finalMillis = currentMillis - previousMillis;  
      Serial.println(finalMillis);
      
      previousMillis = finalMillis;
     //finalMillis = 0;
   }
}

Here, it is my serial monitor output.

on
number of button pushes:  1
0
on
number of button pushes:  2
775
on
number of button pushes:  3
873
on
number of button pushes:  4
1425
on
number of button pushes:  5
1496
on
number of button pushes:  6
2073
on
number of button pushes:  7
2010
on
number of button pushes:  8
2643
on
number of button pushes:  9
3052
on
number of button pushes:  10
3195
on
number of button pushes:  11
3396
on
number of button pushes:  12
3575
on
number of button pushes:  13
3737

First, there is NOTHING magic about the use of millis in the name of the variables. So, get rid of it. If you stop thinking that millis does something magic, it is likely that you will see the problem. finalMillis is NOT a time.

You probably should dump that code, and look at the state change detection example. You will learn how to determine when a switch has become pressed or has become released. It is the (relative) time of these two events that is of interest.

Paul is correct that there are better ways to do this. But the problem with your code is in the final
previousMillis = finalMillis;
I think this should be
previousMillis = currentMillis;

PaulS:
First, there is NOTHING magic about the use of millis in the name of the variables. So, get rid of it. If you stop thinking that millis does something magic, it is likely that you will see the problem. finalMillis is NOT a time.

You probably should dump that code, and look at the state change detection example. You will learn how to determine when a switch has become pressed or has become released. It is the (relative) time of these two events that is of interest.

Ok, got it. Thank you for your suggestion.

jdelcamp11:
Paul is correct that there are better ways to do this. But the problem with your code is in the final
previousMillis = finalMillis;
I think this should be
previousMillis = currentMillis;

Yeap. Now, it's working fine. Thank you.