unexpected result with millis

Are you using real electro-mechanical relays? i.e. coil activated?
If so, it seems unlikely that they can do much in 1ms.

The current code turns on the pin and off again 1ms later.

If the relay is supposed to energize turn on when the pin is high,
it would seem unlikely that it would be able to fully energize fully in 1ms.

But the biggest thing to check is to see if the loop is taking longer than 1ms.
Wouldn't surprise if it was. Theres a lot of 32 bit math going on in that loop.
If it is longer than 1ms whacky things will happen.
You'll need to time it with a analyzer or scope using a spare i/o pin.

Since your numbers are all small, you might try a quick test using 16 bit values instead.
Try declaring time as a unsigned int instead
and then use:

time = (uint16_t) millis();

to use only the lower 16 bits.

--- bill