you are not checking the millis() in your loop so it will not update you just set millisec to whatever it was when it passed it in setup. needs to be in loop
"else if" is not a loop. "for" and "while" are loops. "if else" executes the lines of code inside it once, but conditionally.
If you want to measure the total time that your sensor is triggered (or not triggered), you need to detect the moment the sensor becomes triggered and record the value of millis() at that moment. At the moment the sensor ceases to be triggered, you can calculate the time it was triggered for and add this to the total.
unsigned long markTime; // default is zero
//........... and below, somewhere in loop or a function called by loop
if ( digitalRead( irSensePin ) == HIGH )
{
markTime = millis(); // in 1 second, millis() - markTime will be 1000
// the end - start = elapsed formula works across rollover,
// never needs checking, max interval is > 49.71 days.
}
Contact switches, buttons and like "bounce" on change. Debouncing involves time.