The state of your skin is paramount to how long your self-tan stays on – and how perfect is the result.
While it's necessary to apply after a bath or shower to ensure there are no dirt or dead skin cells to impede absorption, doing so too soon could mean skin's still sweating or moist from the water, which will make the self-tan look patchy. And you need to apply moisturiser beforehand to help reduce patchiness on dry areas. But again, if you use the self-tan on top too soon after applying the moisturiser, it will weaken the result.
The easiest application and most even result comes from bathing and moisturising at night – with a thick, intensive product – and then applying self-tan the next morning (leaving time for it to dry before putting on your clothes, of course) when skin's still soft but not moist.
Just make sure you won't be going to the gym for the next few hours – because sweating while the product develops could give a streaky result.