We are frequently asked in the office about how long breast milk and formula can be safely stored. The major risks for going past this limits is accidentally introducing an unhealthy bacteria to the infant ("spoiled milk") or the breast milk or formula having its ingredients break down.
Although you can find a wide variety of guidelines on the Internet, I find it easier to keep it simple to remember: follow the Rules of Six for breast milk storage. Breast milk can be safely consumed if stored for 6 hours at room temperature, 6 days in the refrigerator, and 6 months in the freezer. If the breast milk is kept in an insulated cooler bag, it should be used within 24 hours.
The guidelines for formula are different. A bottle of formula should be kept at room temperature for no more than 1 hour. Formula prepared from powder then stored in the refrigerator should be used within 24 hours. Formula prepared from concentrate or ready-to-feed formula may be stored in the refrigerator for 48 hours. A can of powdered formula should be used within 30 days of opening.
Here is a link to some more detailed information about safely storing breast milk from the Centers for Disease Control. Here is a link to an article about storing infant formula from Healthy Children.