According to Einstein's theory of relativity, the speed of light is a universal constant, and all other forces, such as the flow of time, will adjust themselves to ensure that the speed of light remains a constant value. Normally, due to the relatively weak gravitational impact of the world around us, we do not notice the effects of this phenomenon. There is one kind of place in the universe, however, where relativity is put to the test, black holes.
The force of gravity stretches the fabric of space-time, depending on how massive the given object exerting gravitational forces is. The way graviy distorts space would make it to where light must adjust speed to cover the same distance in the same amount of time. However, because the speed of light must remain constant, it is time itself that must adjust to ensure that the constant remains. Due to this effect, a person or object that is closer to a massive object will experience a normal progression through time while the rest of the universe travels through time at a faster rate. The person near the massive object thus appears to be slowed from the perspective of an outside viewer.
Due to the unfathomably immense density of black holes, this phenomenon is experienced to a massive degree when in proximity to one. A person very near to a massive black hole could age what is functionally to them only a short period of time, while the rest of the universe around them ages by years, centuries, millennia, or more.
Because of how this works, it is possible that if one could find a way to safely generate and contain a black hole, one could use this to travel far forward in time while remaining practially the same age.
Traveling backwards in time is a whole entire other ordeal. If one is to use relativity to facilitate travel in time, the user would need to be in proximity to a source of negative gravitational forces, which would in theory force time to shift to a negative value to ensure the speed of light remains constant. This could be achieved by the theoretical "white hole," an object which expels matter and energy, and is impossible to enter, essentially being the opposite of a black hole. All of this, however, is purely theoretical, and has no functional example in any means observable by modern science.
Another important thing to note is that a time traveler must be weary of one's location while time traveling. While standing on one's planet, it seems as if everything is stationary, however, everything in the universe is constantly moving at rapid speeds. Planets, stars, even galaxies are all moving about the universe at blinding speeds, creating a scenario where essentially no object is ever in the same place. Without some sort of device to adjust one's spatial location, a time traveler would find themselves somewhere they don't want to be, and statistically, they are probably somewhere in the utterly empty vacuum of space.
An additional note is that if one uses the aforementioned method of forward time travel, doing so in an exposed environment is likely quite dangerous. While the duration of the trip to the time traveler is only a matter of seconds, they are in fact, to those around them, remaining praticially stationary for however long they are traveling. This leaves the time traveler exposed to attack or natural disaster, which may injure or kill the traveler before they even realize what has happened. As such, it is advisible to pursue the act of time travel in some sort of protected environment.
A different way in which forward time travel could work still utilizes the theory of relativity, but instead of manipulating gravity, the traveler manipulates speed. The faster you move, the more energy you are sapping from your movement in time and adding to your movement in space. If it was possible for one to move through space at extremely high rates without becoming heavily disfigured or destroyed, they would effectively slow the passage of time relative to themselves. If one could travel at the speed of light itself, they would effectively stop their individual movement through time altogether (the subject would not age a second, however everything around them would).
Traveling backwards in time using this method is theoretically impossible given that all known laws of physics remain intact, as forcing time to become a negative value would require exceeding the speed of light, which is impossible, the breach of which would destroy a number of universal functionalities that ensure the facilitation of physics itself. Breaching the speed of light, if at all possible, would likley have a number of highly destructive consequences, although we simply cannot know.