They're both good sentences, but the nuances of the structures give them different meanings.
With "... he took time to visit his friends", the focus is on the significance of his decision to use his time time to visit his friends. Take time to do something implies it's important to do and has a positive feeling. It's often phrased, "... he took time out of his day to...", which makes it clear it's a sacrifice.
With "... he took time visiting his friends", the focus is on how spent limited time in New York. Take time doing something simply implies it cost time and has a negative feeling, perhaps of wasted time, or of a lack of time now.