Pokemon GO uses GPS location to detect cheaters in the game. In order to bypass this detection, you must wait a certain amount of time between actions you take.
The period of time you must wait between actions fully depends on how far apart the two locations are. But the general rule of thumb is to wait 120 minutes (2 hours).
Once two hours from your last action (placing / fighting in a Gym, spinning Pokestop, throwing a Pokeball at a Pokemon, etc), you are free to do an action in a new location.
If you catch a Pokemon at 2pm, and you travel to the other side of the world, you can not perform any actions in the new location until it is 4pm.