Your description matches the plot of K-PAX (2001), except that the protagonist claimed to be an alien rather than a time traveller.
K-PAX is a 2001 science fiction mystery film based on Gene Brewer's 1995 novel of the same name. An American-German co-production, it was directed by Iain Softley, starring Kevin Spacey, Jeff Bridges, Mary McCormack, and Alfre Woodard. The film is about a psychiatric patient who claims to be an alien from the planet K-PAX. During his treatment, the patient demonstrates an outlook on life that ultimately proves inspirational for his fellow patients and especially for his psychiatrist.
After claiming he is an extraterrestrial from the planet 'K-PAX', 1,000 light years away in the Lyra constellation, prot (not capitalized and pronounced with a long O, rhyming with boat) is committed to the Psychiatric Institute of Manhattan. There, psychiatrist Dr. Mark Powell attempts to cure him of his apparent delusions. However, prot is unwavering in his ability to provide cogent answers to questions about himself, K-PAX, and its civilizations. His medical examination only reinforces his story, as prot can see ultraviolet light and he is completely resistant to the effects of Thorazine. Powell introduces him to a group of astrophysicists who are befuddled when prot displays a level of knowledge about his claimed star system that was unknown to them.
prot also wins over the other patients at the Institute, each of whom believes unquestioningly that he is indeed from K-PAX. prot, who claims to have journeyed to Earth by means of "light-travel", explains that he can take one person with him when he returns. Thereafter, most of the patients at the Institute ask prot to take them with him.
Upon learning that many of his patients expect to leave Earth on July 27, Powell confronts prot, who explains that it is a predetermined date. However, Powell believes this to be a significant date in prot's life, a day on which he suffered a severe psychological trauma. Powell decides to subject prot to regression hypnosis, which works well. Using information gained from these sessions, Powell figures out that prot may simply be an alter ego of Robert Porter, a man from New Mexico who attempted suicide in 1996 after his wife and child were murdered. Powell tries to confront prot with this knowledge, but prot's reaction is one of bemusement, and he cryptically tells Powell that he hopes he will take good care of Robert now that he has found him.
On July 27 as the hospital staff watch, the camera in prot's room cuts to static at the precise time prot said he would leave Earth. Powell finds Porter lying on the floor in his room, catatonic, prot having apparently left Porter's body for the light travel back to K-PAX. As Robert is being wheeled out of the room, the other patients do not recognize him. In addition, one of the patients is missing: Bess, a woman who had remained mute since her home was destroyed in a fire and who had been among the patients that asked to go to K-PAX with prot. She is never found. Powell continues to take care of the catatonic Porter and tells him about how the patients he helped have gone on to live normal lives again, but Robert does not respond. Powell is left with no absolute answer as to whether prot was in fact an alien entity or just a coping mechanism of the traumatized Porter, but seems far from convinced that Porter's behavior was a delusion.
In a final voiceover, prot explains to Powell that the people of K-PAX have discovered that our universe will repeat its events again and again, so the mistakes we make will be repeated forever. prot encourages Powell to make this time count, as it is the only chance we have. Inspired, Powell begins a new, better life by reconciling with his estranged son.