Alternatively, you can take advantage of gravitational time dilation (general relativity). While entrance B experiences 5 years (for example), entrance A experiences 5,000 years (for example). Since they’re “connected at the same age”, stepping through the B entrance will take you back to the time when the A entrance was 5 years old, which was 4,995 years ago. As for how exactly the mechanics of time travel works, what with grandfather paradoxes and what not, I couldn’t say. The methods used to create, stabilize, and move wormholes generally involve some pretty abstract (“abstract” = “impossible”) math and physics.