Depends on the situation. Sometimes they only find out that the planet they’re beaming down to is actually a 1920’s mafia planet or a Nazi Germany planet after the fact once they get there, and then it’s like, “Bones, Spock, and also random Crewman, we’ve just beamed down to a mafia planet, we need to get some proper clothes before we’re spotted. Oh no, we’ve been spotted, beat these mafia guys up and steal their clothes quick before we’re spotted again.”
Although to be fair those sorts of episodes actually didn’t involve time travel, since they were other planets that for some reason or another became entire planets of mafiosos and Nazis, but the prime directive still applied.