You need Vitamin D. Your body uses the sun’s UVB rays to make it.

You also need sunscreen. Sunscreen blocks UVB rays.

Confused? Don’t be.

There are a lot of conflicting – and plain old wrong – messages out there about how to get enough vitamin D, particularly when it comes to sunshine. We spoke with Dean David George, MD, FAAD, medical director of cutaneous oncology at the Hartford Healthcare Cancer Institute, who strongly recommends the following:

Don’t get your vitamin D from the sun.

Yes, sunshine is one way to get vitamin D. But it means baring your skin to the sun’s rays, without sunscreen, for 15 minutes or more. That short amount of time might sound harmless, but it’s not.

Unprotected exposure to UV rays, even for short periods of time, is a known risk factor for deadly skin cancers, including melanoma,” says Dr. George. “It’s not worth the risk. If you need vitamin D, get it from food or a supplement, not the sun.”

Don’t even get dermatologists started on indoor tanning. Run, don’t walk, away from tanning beds.

The American Academy of Dermatology agrees: Get your vitamin D another way.

There are plenty of other sources.

It’s important not to neglect vitamin D altogether. Along with calcium, it plays a crucial role in bone health, and recent studies show it may also play a role in regulating emotions and preventing depression.

But the majority of people can get their vitamin D from nutritional supplements and certain foods. In fact, the National Academy of Medicine (NAM) created its recommended daily values without taking sunshine into account, because sun exposure is such an inconsistent source – not to mention risky.

NAM recommends that adults up to age 70 get 600 International Units (IUs) of vitamin D per day, and adults age 71 and older get 800 IUs per day. Ideally, most of that will come from foods naturally rich in the vitamin. Think: fatty fish including salmon and tuna, and fortified foods like milk and orange juice.

Your vitamin D regimen can also include supplements in pill or liquid form, like a simple multivitamin. Talk to your doctor about what’s right for you.

Meanwhile, double-check your sun protection.

Now you know: Because of the risks of UV rays, sunshine is not a safe way to vitamin D.

So, how to stay protected? Here’s a refresher.

Plan ahead when you’ll be outdoors,” says Dr. George. Seek shade whenever possible, and when you can’t avoid the sun, layer up with broad spectrum SPF 30 or higher sunscreen and protective clothing. Keep in mind that the sun’s UV rays are strongest between the hours of 10 a.m. and 4 p.m.

When you’re choosing sunscreen, go with a water-resistant brand, and apply it to any skin that’s not covered by clothing. Reapply every two hours or immediately after swimming, sweating or toweling off.

“Using sun protection whenever you’re in the sun will not only help prevent skin cancer but premature skin aging as well.” says Dr. George.