This is Disney's 1986 film, The Flight of the Navigator
On the night of July 4, 1978, in Fort Lauderdale, Florida, 12-year-old David Freeman walks through the woods to pick up his 8-year-old younger brother, Jeff, from a friend's house when he accidentally falls into a ravine and is knocked unconscious. When he comes to, he discovers that eight years have passed and it is now 1986. Police are shocked to see David fits exactly the same photo on a missing child poster, not having aged at all. David is reunited with his aged parents and Jeff is now 16. Meanwhile, an alien spaceship crashes through power lines and is promptly captured by NASA. David is taken to the hospital for tests where his brainwaves reveal images of the spaceship. Dr. Louis Faraday, who has been studying it since its arrival, persuades David to come to a NASA research facility for just 48 hours for extra tests, promising him that they can help him learn the truth about what happened to him. There, Dr. Faraday discovers that David's mind is filled with alien technical manuals and star charts covering expanses of the galaxy far exceeding NASA's research. It tells the scientists that he was taken to a planet called Phaelon, 560 light years away, in just over 2.2 hours. They realize that he has experienced severe time dilation as a result of having traveled faster than the speed of light, explaining why eight years have passed on Earth, but not for him. He is unable to comprehend what Dr. Faraday tells him and flees the room, leaving Dr. Faraday muttering that 48 hours will be insufficient to finish his investigation.
The next morning, following a telepathic communication from the spaceship, David secretly boards it and meets its robotic commander, "Trimaxion Drone Ship" (or "Max" for short), which refers to David as the "Navigator". After they escape from the facility, Max tells David that his mission was to travel across the galaxy, collect biological specimens, take them to Phaelon for analysis, and then return them to their homes. Phaelon's scientists discovered humans only use 10% of their brain and, as an experiment, filled the remainder of David's with miscellaneous information. This includes all of the star charts discovered by Phaelon's astronomers, some of which were shown to the NASA scientists during David's interrogation. Max then returned him to Earth, but did not take him back to his own time, having determined that a human would be unlikely to survive a trip back in time. Before leaving Earth, Max accidentally crashed the spaceship, erasing all the computer's star charts and data. Therefore, he needs the information in David's brain to return home....