It varies for each pig but typically they can take weeks to months to warm up. They're prey animals so they are naturally skittish and this is something you cannot change. Even very friendly and tame pigs will run for their lives when you're trying to pick them up.
I have 4 girls who are very social but they will run from me when I'm trying to lift them. It didn't take any of them long to enjoy lap time though.
It depends on the pig. Some will be fine right away, but others can take weeks, months or even a year to warm up to you. Try to spend a lot of time with them just talking softly, hand feeding veggies, and petting them if they'll let you.
Every guinea pig is different. Yesterday, I got a pig (she is in quarantine at the moment) and she is already coming up to the sides of the cage to see me. About two months ago, I got a different pig, Puffy. Puffy is still very skittish around me and is very cautious. Really, it depends on the pig's personality and previous experiences. Most of the time, the maximum amount of time it will take for your piggy to get used to you is one year. In my experience three weeks is the average.
Most guinea pigs will never like being lifted out of their cage and will try to run away when they see your hands coming. All 4 of my pigs (2.5 years, and 8 months old) run for their lives when I'm trying to pick them up but once I'm holding them they are happy and friendly.