When cooking corn on the cob in foil on a grill it takes between 20 to 30 minutes depending on how well done you like the corn.
When you place the corn on the cob in the foil and place it on the grill allow it to grill on one side for 5 or 10 minutes and then flip the corn on the cob over to cook the other side and repeat the process of turning the corn on the cob over and over until 20 to 30 minutes is up.
I like to cook my corn on the cob on the grill in the tin foil for 30 minutes but some people like theirs cooked for 20 minutes.
Before wrapping the corn on the cob in foil I also like to sprinkle on some garlic on my corn on the cob which gives it a good flavor.