Break from while loops after specific time

unsigned long stop = millis();
while(millis()-stop<1000&& whatever){
i'm doing whatever for 1 second

}