Help with motors

Hello, I need help with an idea a want to code, but I can't.

I want to make four motors move forward for x seconds. I have thought of using delay(), but this is not going to work. The library I have used for controlling the motors is the Adafruit Motoshield V2.

void speedForward(int speed)
{
	speed = map(speed, 0, 100, 0, 255);   //here I transform the pwm signal of the motors into porcentage
	m1->run(FORWARD);    //motors have to move forward
	m2->run(FORWARD);
	m3->run(FORWARD);
	m4->run(FORWARD);
	m1->setSpeed(speed);    //set speed of the motors
	m2->setSpeed(speed);
	m3->setSpeed(speed);
	m4->setSpeed(speed);
}

I want for example to run this code for 5 seconds.

Does someone know how to do it?

Thank you.

You could look at the blink without delay example in the IDE for clues

I have looked it up but I dont understand this:

if (currentMillis - previousMillis >= interval)

It's not going to be 1000 milliseconds, it's going to be much more than that.
Could you please explain that to me?

Thank you.

jac4:
I have looked it up but I dont understand this:

if (currentMillis - previousMillis >= interval)

It's not going to be 1000 milliseconds, it's going to be much more than that.
Could you please explain that to me?

Thank you.

I want to make four motors move forward for x seconds.

Would " x times 1000 milliseconds" work for you?