Tomorrow Is Yesterday is a first season episode of Star Trek: TOS. In it, the Enterprise is thrown back in time due to an accident and finds itself flying- damaged- through Earth's atmosphere in the 1960's where it is picked up by a US military radar. Fighters are scrambled to intercept the UFO and one of them gets close enough to take pictures and provide a description of the Enterprise. Captain Kirk orders his crew to place a tractor beam on the jet. Unfortunately, the fighter was not designed to withstand such pressure and it starts to break apart. Kirk must have the pilot beamed aboard to save his life.
The pilot- Captain John Christopher- is naturally astonished at finding himself on board a starship from the future. His shock turns to anger, however, when he is regretfully informed by Kirk that he cannot return to Earth because, having seen them, he could change the timeline. Spock, who has been studying historical records, tells Kirk that he's discovered something that makes it imperative that Christopher be sent back: his son will be a member of the first mission to Saturn. If Captain Christopher is not returned to his own time, his son will never be born and history will be changed.
This isn't Kirk's only dilemma... he also has to figure out how to get back the photos taken by Christopher because they find out the films have been recovered from the plane's wreckage and are awaiting being developed at a US airbase. Kirk and Sulu beam into the base at night to try to recover the pics but get caught by a security guard who, while examining Kirk's communicator, accidentally turns on its emergency signal. Thinking Kirk is in trouble, the ship zeroes in on its coordinates and beams up the guard. So now they have two problem "guests" on board the Enterprise.
Kirk and Sulu continue their search, but are found out again; Kirk is recaptured but Sulu escapes and returns to the ship. While Kirk is interrogated, Spock and Sulu beam down to get Kirk and the photos, bringing Captain Christopher with them because he knows the layout of the base. After they subdue the guards, Christopher grabs a gun and says that he's staying there. Spock nerve-pinches him and they all return to the Enterprise with the photos in their possession.
Back on board, Scotty announces that he's found a way to return the Enterprise to its own time; using the sun to create a slingshot effect which will impel them ahead in time. They first have to move backwards in time, and manage to return both Christopher and the guard back to Earth before they actually encounter the Enterprise or its crew. They then are flung ahead in time, successfully returning to the 23rd century.