I need a program to run Arduino for x time then stop

I need help to program Arduino to drive DC motor and stop after X seconds

I would like to just change the X as what I want

pleaseeeeeeeeeeeee help me

  analogWrite(motorPin, speed);
  delay(X);
  analogWrite(motorPin, 0);

Your requirements are far too hazy to even think about firing up the IDE.

What is supposed to trigger the motor to start spinning? Which direction? How fast? Using what between the motor and the Arduino?