After Captain Jack Harkness was made immortal, the Doctor and Rose left him on Satellite 5 in the year 200,100. Next time we see him, he's on Earth, and has been there waiting to run into the Doctor again since at least the 1800s, although he drops hints that imply he's been there for longer.
Perhaps some of those hints are from his time as a 51st century Time Agent, but it's unclear. I've seen all of the modern Doctor Who and most of Torchwood, and I don't recall learning how he ended up on Earth or what year he arrived, which is what I'd like to know.