Using debounce with interrupt for pushbutton

Hi, I want to use the interrupt method for a switch in rotary encoder but I have found a bouncing problem, so after searching, I have found this code, but I don't know if it's good or there are other better solutions

long debouncing_time = 15; //Debouncing Time in Milliseconds
volatile unsigned long last_micros;
volatile boolean pushed = false;

void setup() {
pinMode(2,INPUT);
 attachInterrupt(0, debounceInterrupt, FALLING);
}

void loop() {
}

void debounceInterrupt() {
 if((long)(micros() - last_micros) >= debouncing_time * 1000) {
   pushed = true;
   last_micros = micros();
 }
}

If you're talking about the actual encoder function, check out this interrupt-driven encoder library I've been working on: GitHub - gfvalvo/NewEncoder: Rotary Encoder Library
It handles debounce without timing delays. Both encoder pins must be connected to interrupt-capable inputs on your board.

If you're talking about the push button switch on many encoders (the extra two pins), then don't bother with interrupts, just use the Bounce2 library.

did you have a look at this link?

https://playground.arduino.cc/Main/RotaryEncoders

gfvalvo:
If you're talking about the push button switch on many encoders (the extra two pins), then don't bother with interrupts, just use the Bounce2 library.

Yes this what i'm talking about , so the best solution is using the Bounce library

aymannox:
so the best solution is using the Bounce library

"Best" is probably a little subjective and dependent upon the application. I prefer Bounce2 for most uses.

gfvalvo:
"Best" is probably a little subjective and dependent upon the application. I prefer Bounce2 for most uses.

Ok,thanks for your help.