Having sun, without burning, actually helps a lot.
The key to gaining vitamin D from the sun though is not washing the parts of your body that were exposed to the sun for 24-48 hours. Since many people wash daily, it limits your ability to absorb vitamin D from the sun.