use millis() in external interrupts

can i use millis() function in externatl interrupts? I want to measure the interrupts elapsed time between start and end.

You can use millis() in an ISR in the sense that you can read a value from it, but it will not update within an ISR. However, even if it worked the ISR should not really take as long as an millisecond to execute

The micros() function does update when in an ISR but be aware that it increments in steps of 4, not in steps of 1

void INT0_ISR(void)
{  
  
      motordurum= digitalRead(motorokuma);
                 
                     

                     startzaman = millis(); // start time
                     Serial.println(startzaman);
                     while(digitalRead(kesme)==0);
                    
                     stopzaman = millis(); // stop time
                     Serial.println(stopzaman);
                     zaman = (startzaman - stopzaman)/1000;
     
                     Serial.print("buton bırakıldı zaman:");
                     Serial.println(zaman);
}

UKHeliBob:
You can use millis() in an ISR in the sense that you can read a value from it, but it will not update within an ISR. However, even if it worked the ISR should not really take as long as an millisecond to execute

The micros() function does update when in an ISR but be aware that it increments in steps of 4, not in steps of 1

thank you but micros() dont update in ISR

Don't Serial print in a IRS. Although you don't have the risk of overflowing the buffer anymore, it is bad practice. Because if the buffer is flow, the actual printing is done in the ISR and will be slow.

while(digitalRead(kesme)==0);

Why is this in an ISR ?

An ISR should execute as quickly as possible. Maybe set a flag to indicate that it has occurred and save the current value of millis(). Then the interpretation of the data should take place in the main code

micros() dont update in ISR

Have it your own way

Why do you think that you need to use an interrupt in the first place ?
What are you trying to do ?

UKHeliBob:

while(digitalRead(kesme)==0);

Why is this in an ISR ?

An ISR should execute as quickly as possible. Maybe set a flag to indicate that it has occurred and save the current value of millis(). Then the interpretation of the data should take place in the main code
Have it your own way

Why do you think that you need to use an interrupt in the first place ?
What are you trying to do ?

I start the pump motor to fill a container with water. There is 1 button.
normally i want powersave mode at arduino. and after start program arduino in powersave mode. at 1 buton firstly i wakeup arduino . after that I want to take action according to the time the button is pressed. For example, if the time is less than 1 second, a small container will be filled with water. If the time is greater than 2 seconds, a large container will be full.

Wake up the Arduino then do the button press timing in the main program using millis() for timing