millis() function not work above difference

Hello Community!

I have a question that is bothering me a couple of days already and maybe someone else has an solution for it.

When I run the following code on my Arduino Mega

boolean loggedIn = false;
unsigned long currentTime = millis();
unsigned long loggedInTime = 0;
//int loginTime = 300000;
int loginTime = 60000;

//The part below is in the main loop function

if(millis() - loggedInTime > loginTime){
      loggedIn = 0;
      Serial.println("Logged out");
    }

It works if the loginTime = 30000, but it does not work if the loginTime = 60000
Does someone has an explanation for that?

Thanks in advance!

With kind regards,
Arthur

SOLUTION:

The solution is that an int can hold a 16 bit value, so since it is 2’s complement it can hold an value up to maximum of (215-1)

int loginTime = 60000;What is the largest number that an int can hold ?

int loginTime = 60000; >>>----> unsigned long loginTime = 60000UL;

The number you have commented out is not 30000.