Save the value of millis() as the start time when the button becomes pressed and set a boolean to true to flag that timing is in progress. If the button becomes released set the boolean to false. Each time through loop(), if the boolean is true check whether 5 seconds has passed since it was pressed by subtracting the start time from the current value of millis(). If so take action as desired
use a timer, so when the button is pressed, the timer starts and after 5s go to timer interrupt and check if the button is still HIGH and then perform what you want