In the Star Trek: The Next Generation episode "Time Squared", the Enterprise-D was sucked into a spatial anomaly known as an energy vortex - a spinning, turbulent local temporal continuum anomaly comprised of pure energy. In an attempt to save the Enterprise, Picard left the ship in a shuttlepod, to distract its attention long enough to allow the Enterprise to escape.  The Enterprise was destroyed in the vortex but Picard was thrown back in time six hours. After the Enterprise encountered the future Picard, it experienced the encounter with the vortex once again, only with a different outcome.

The effects of that energy vortex - strong gravitational fields and the ability to travel through time - appear to be similar to effects one may find near a black hole. According to Einstein's theory of general relativity, in the presence of a gravitational field, an external observer would see a clock in a strong gravitational field tick more slowly. If you were traveling into a strong gravitational field and sending out pulses of light every second, an observer watching these signals from a great distance would see the interval between the pulses increase from seconds to minutes and then hours as the field got stronger and stronger. Black holes are  sources of inctredibly strong gravitational fields - in principle, if you could get within a few millimeters of an Event Horizon before escaping, you could essentially time travel years or millenia into the future as measured by outside clocks. According to your clock, however, perhaps only a few hour or days actually elapsed.

However, you would only be able to travel forward in time and not, as in the case with Picard in "Time Sqaured", backwards.

Illustration of light deflection near a Black Hole, with
the the observer sitting at 5 Schwarzschild radii.