Time Sensitive Loop

i'm trying to run a task in more than a minute and back to the second task for a few seconds.

this is my code

unsigned long timeReset=0;
int interval1 = 5000;
int interval2 = 60000;




void setup() {
  // put your setup code here, to run once:
    Serial.begin(9600);
    
}

void loop() {
  // put your main code here, to run repeatedly:
              timeReset = millis();
              while((millis() - timeReset) < interval1){
                Serial.println("1st task");
                delay(1000);
              }


              Serial.println("");Serial.println("");


            timeReset = millis();
              while((millis() - timeReset) < interval2){
                Serial.println("2nd task");
                delay(1000);
              }

               Serial.println("");Serial.println("");
}

as you can see the 2nd task is 6000ms=60sec= 1min. but when i run it, it does not go back to the 1st task thus continue infinitely . when i try to put 30000ms it goes back to 1st task. can anyone help me how to maximize of extend it to more than a minute? thanks.

Time intervals need to be declared as “unsigned long”, rather than “int”

it works, thank you sir

alexis27:
it works, thank you sir

Do you know why it works ?