millis sketch not working with long durations

I have the following sketch which i want to turn a pump on fee about 2.25 minutes for every 1 hour. The sketch works when the period is every 15 seconds or less. However, any duration on or off timbre greater than 15 seconds and the pump stays on perpetually. I have resorted to a delay( ) sketch in the time being.

Thanks in advance, Sean

millis( ) sketch:

// These variables store the flash pattern
    // and the current state of the LED
     
    int ledPin =  12;      // the number of the LED pin
    int ledState = LOW;             // ledState used to set the LED
    unsigned long previousMillis = 0;        // will store last time LED was updated
    int a = 1; //time on in seconds
    int b = 6; // period (time on and off in seconds)
    int on = a*1000; //time on msec
    int off = (b-a)*1000; //time off msec
    long OnTime = on;           // milliseconds of on-time
    long OffTime = off;          // milliseconds of off-time
     
    void setup() 
    {
      // set the digital pin as output:
      pinMode(ledPin, OUTPUT); 
    }
     
    void loop()
    {
      // check to see if it's time to change the state of the LED
      unsigned long currentMillis = millis();
     
      if((ledState == HIGH) && (currentMillis - previousMillis >= OnTime))
      {
        ledState = LOW;  // Turn it off
        previousMillis = currentMillis;  // Remember the time
        digitalWrite(ledPin, ledState);  // Update the actual LED
        Serial.print(" pump on    ");
        Serial.print(currentMillis/1000/60/60);
        Serial.print( ":");
        Serial.print(currentMillis/1000/60);
        Serial.print( ":");
        Serial.println(currentMillis/1000);
      }
      else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime))
      {
        ledState = HIGH;  // turn it on
        previousMillis = currentMillis;   // Remember the time
        digitalWrite(ledPin, ledState);   // Update the actual LED
        Serial.print(" pump off    ");
        Serial.print(currentMillis/1000/60/60);
        Serial.print( ":");
        Serial.print(currentMillis/1000/60);
        Serial.print( ":");
        Serial.println(currentMillis/1000);
      }
    }

delay() sketch

void setup() {
  // initialize digital pin 13 as an output.
  pinMode(12, OUTPUT);
  Serial.begin(9600);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(12, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(870150);  
  Serial.println(" pump on    ");  // wait for a second
  digitalWrite(12, LOW);    // turn the LED off by making the voltage LOW
  delay(29850);  
  Serial.println(" pump off    ");  // wait for a second
}
    int on = a*1000; //time on msec
    int off = (b-a)*1000; //time off msec
    long OnTime = on;           // milliseconds of on-time
    long OffTime = off;          // milliseconds of off-time

on and off are useless variables.

Directly assign values to OnTime and OffTime, based on multiplying by 1000UL, not 1000.

        digitalWrite(ledPin, ledState);  // Update the actual LED
        Serial.print(" pump on    ");

You have an LED that looks like a pump?

        Serial.print(currentMillis/1000/60/60);
        Serial.print( ":");
        Serial.print(currentMillis/1000/60);
        Serial.print( ":");
        Serial.println(currentMillis/1000);

Pretending that the number of milliseconds since the Arduino started is in any way related to wall clock time is silly.

In addition onTime and offTime shoud be unsigned long. Right now you are using signed variables which may or may not cause some weird issues down the road.

int on = a*1000; //time on msec

The problem here is that once a is larger than 16, the result of that calculation doesn't fit into an integer anymore and overflows possibly even giving you a negative number.

The problem here is that once a is larger than 16, the result of that calculation doesn't fit into an integer anymore and overflows possibly even giving you a negative number.

I think you misspelled 32.

Dam, I do that all the time.

Or smaller than -32 ...