You say this works but the way it is written it will be true once the program has been running for more that 5 seconds. 49 and a bit days later it will be false for 5 seconds then go back to being true. I don't think that the program is doing what you think it is but then you only posted a snippet rather than a full program
if (timer == interval)
Will be true for 1 millisecond each 49 and a bit days