We've all been guilty of leaving milk out of the fridge at some point in our lives. Maybe you accidentally left milk out for an afternoon after pouring a bowl of cereal, or, after grocery shopping, you ran another errand with a gallon of milk in the decidedly unrefrigerated trunk of your car. And we all know it's a bad idea to leave milk unrefrigerated for an extended period of time because it might spoil—but how long is too long? How long can milk be out of the fridge and still be safe to drink?

The answer is slightly different depending on where you live. Most of the milk consumed in France, Belgium, and Spain, for example, is UHT, or ultra-high temperature milk. This means it doesn't need to be refrigerated. But in the United States, pasteurized milk must be refrigerated, according to the US Food and Drug Administration. "By law, Grade A milk must be maintained at a temperature of 45°F or below," say food-safety specialists at Clemson University. Ideally, milk should be stored on your fridge's bottom shelf at a temperature between 38 and 40°F. That's because the bottom shelf, according to the Dairy Council of California, is the coldest part of your fridge, so it's the best spot for readily perishable items like milk.

Why do you need to be careful about the way you store milk? If milk is left out of the fridge for an extended period of time it can become a food-safety issue. Bacteria start to grow and replicate when the temperature of your milk reaches 40°F, and those bacteria are how you end up with a gallon of nasty, rotten milk or, at worst, contract an illness. 

According to the US Food and Drug Administration, refrigerated foods, including milk, should never be out of the fridge at room temperature for longer than two hours. That window closes quickly if the ambient temperature rises. "If the temperature is above 90°F, food should not be left out more than 1 hour," the US Food and Drug Administration says. That's part of the reason the Dairy Council of California recommends going straight home after grocery shopping and immediately putting your milk in the fridge.

If you do accidentally leave milk out on the counter for a couple of hours, you won't necessarily get sick from drinking it—but you're not helping your chances. So refrigerate your milk as soon as you get home, and leave it in the coldest part of the fridge when you're not using it. If nothing else, you'll limit your chances of smelling rotten milk, which, in my opinion, is a win in and of itself.