How does tan develop (from Wikipedia)

There are two different mechanisms involved in production of a tan by UV exposure.

Firstly, UVA radiation creates oxidative stress, which in turn oxidizes existing melanin and leads to rapid darkening of the melanin. UVA may also cause melanin to be redistributed (released from melanocytes where it is already stored), but its total quantity is unchanged. Skin darkening from UVA exposure does not lead to significantly increased production of melanin or protection against sunburn.

In the second process, triggered primarily by UVB, there is an increase in production of melanin (melanogenesis), which is the body’s reaction to direct DNA photodamage from UV radiation. Melanogenesis leads to delayed tanning, and typically becomes visible two or three days after exposure.

The tan that is created by increased melanogenesis typically lasts for a few weeks or months, much longer than the tan that is caused by oxidation of existing melanin, and is also actually protective against UV skin damage and sunburn, rather than simply cosmetic. Typically, it can provide a modest Sun Protection Factor (SPF) of 3, meaning that tanned skin would tolerate up to 3 times the UV exposure as pale skin. However, in order to cause true melanogenesis-tanning by means of UV exposure, some direct DNA photodamage must first be produced, and this requires UVB exposure (as present in natural sunlight, or sunlamps that produce UVB).