The amount of time you can safely spend in the sun depends on your geographical location, part of the year and skin color.
The closer you are to the equator, the stronger the sun is, so you should spend less time exposed to the sun (5-10 minutes daily) and avoid sun zenith time. Further from the equator, you should spend a bit longer to get all of your vitamin D, especially in winter, when sun rays reach have a different angle. In winter, choose midday time, and in summer, avoid it to get too much radiation.
Darker skin has more melanin – skin pigment that protects from UV rays. This means that people should spend more time in the sun to get vitamin D.