The Old Republic and both Knights of the Old Republic are set long before the movies, but how do they mesh with each other? I thought TOR would be after both KOTOR games, but the opening cinematics make it sound like it's all about the reemergence of the Sith after having been in hiding for so long (but making a huge army/fleet?)
According to the Star Wars wikia, Knights of the Old Republic takes place in 3,956 BBY (Before the Battle for Yavin - aka the finale of Episode IV: A New Hope) which is 303 years before the BTC (Treaty of Coruscant).
The Treaty of Coruscant heralds the start of the "Cold War Era", during which The Old Republic is set.
So KOTOR takes place about 300 years before TOR.
Do note that the Opening Cinematic in the game is set in the "Past". For instance, the Jedi that gets away, Satele Shan, is now one of the premier leaders of the Jedi Order, not simply an apprentice as she is in the cinematic.
The faction specific cinematics are also set in the "Past", though they reference events at the end of the Sith-Republic war, rather than the beginning of it, specifically The Sacking of Coruscant and The Battle of Alderaan.
The exact date within TOR is unknown, though it is estimated to be about 20 ATC (After Treaty of Coruscant)
The complete in-universe explanation of how the plotlines fit together is given in the Revan tie-in novel. (Note that despite being the third published in the The Old Republic tie-in novel series, none of the books have anything to do with the others, and indeed Revan takes place chronologically first.)
It ties together the emergence of Revan's Sith to not only the Sith of The Old Republic's Cold War era, but also the Sith of the original Tales of the Jedi comics (Naga Sadow, Ludo Kreshh, Marka Ragnos, et al.). It resolves several outstanding questions from the game, both about Revan's past and the future of Revan and the Exile. Highly recommended.
Slightly-spoilery outline of the main thrust of the book:
More-spoilery summary of the revealed info:
And finally, a spoiler of the end of the novel, tying it all together: