The tanning response to UV occurs in two phases:
1. The immediate response begins at exposure to UV-A, reaches a max at 1-2 hours, and fades between 3 and 24 hours. This article speculates that this is due to the redistribution of melanosomes rather than additional melanin production.
2. The delayed response is more durable, occurring by repeated exposure to UV-B, as well as as UV-A and visible light. "It is a gradual process in which the skin starts darkening 48–72 h after irradiation, reaches a maximum ∼3 wk after exposure, and the skin does not return to its original melanin content until ∼8–10 months later." This source says this is due to additional melanocytes, melanosomes, and more melanin, in general.
Both processes are influenced by genetic factors.
Source for the initial points, which also contains interesting details on the enzymes involved in these processes.