Yes, but man's habits in the 21st century (America, for example, since that's all I know first hand) leave a lot to be desired.
My countrymen spend most of their time indoors, or in a climate-controlled space -- they get little or no unfiltered sunshine or fresh air -- or exercise for that matter.
Scientists now know that the sun gives off 2 kinds of UV rays -- A and B. Type A will pass through glass, but is the kind that causes skin cancer. It also destroys the Vitamin D that has built up in your skin. But Type B doesn't pass through glass, and CREATES Vitamin D when it comes in contact with substances in your skin. Essentially, Type A serves as a limiter, to prevent your body from creating too much Vitamin D.
If you are getting sunshine outdoors, you get Types A and B. If you're inside a house (with glass between you and the sun) you're only getting Type A.
But here's the catch -- to absorb most of the Vitamin D into your body, where it actually can help you, you must not wash your body for 2 DAYS after getting some good sunshine. (I'm not sure what % is absorbed after 1 day, etc.) So the American habit of daily showering can actually hurt your health! Vitamin D is VERY, VERY important for your health, especially for pregnant women.
And the other catch? If you're sitting in your car, you only get type A unless your hand is hanging out of the car window, or the sun is shining in through an open window. If not, you're just getting the harmful Type A UV rays. So "getting a little sun on the way to work" DOES NOT COUNT -- in fact it counts against you!
Matthew