Something is wrong with my millis() timer

I have the following code segment:

int lastTime;
if ((millis() - lastTime) > 5000) {
    Serial.Println("Timer!");
    lastTime = millis();
}

For some reason the timer waits only once for the 5000 ms. After the first time, the function inside the if condition is executed with every program cycle.
I don't know what I'm doing wrong?

Any help would be much appreciated!

Edit: added code tags

Should be "static unsigned long lastTime"

Please remember to use code tags when posting ALL of your code

Thank you for your help.
Sorry for the formatting error, I'm new here.
What do you mean by code tags?

Please follow the advice given in the link below when posting code , use code tags and post the code here to make it easier to read and copy for examination

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.