Dr. Mercola says:
Safe sun exposure is essential for optimal health, but incorrect exposure can raise your risk of skin cancer while not providing any health benefits. Sunburn should be avoided at all cost. Detailed guidelines are provided for safely increasing your vitamin D stores through proper sun exposure are included.
While sunlight is composed of about 1,500 wavelengths, UVB is the only wavelength that will produce vitamin D when hitting unexposed skin. UVA’s increase your risk of skin cancer and causes photoaging of your skin. Therefore, it’s important to determine the ideal times of year for safe and effective sun exposure, and avoid exposure during times that UVB rays are not present. Instructions are included.
Vitamin D3 is an oil soluble steroid hormone that forms when your skin is exposed to UVB radiation from the sun (or a safe tanning bed). When UVB strikes the surface of your skin, your skin converts a cholesterol derivative into vitamin D3. It takes up to 48 hours for this vitamin D3 to be absorbed into your bloodstream to elevate your vitamin D levels. Therefore, it’s important to avoid washing your skin with soap after sun exposure.
In case you do develop a sun burn, immediately apply raw aloe vera. It’s one of the best remedies to help accelerate skin healing.
From a health perspective it doesn't make much sense to expose your skin to the sun when it is lower than 50 degrees above the horizon because you will not receive any valuable UVB rays, but you will expose yourself to the more dangerous and potentially deadly UVA rays. UVA's have a longer wavelength than UVB and can more easily penetrate the ozone layer and other obstacles (like clouds and pollution) on their way from the sun to the earth. UVA is what radically increases your risk of skin cancer and photoaging of your skin. So while it will give you a tan, unless the companion UVB rays are available you're likely doing more harm than good and should probably stay out of the sun to protect your skin.