I work for a Class II Medical Device manufacturer and I can confirm what Al wrote. If people waited for actual aging data on a new drug, nothing would ever get launched to the marketplace. Therefore, "accelerated aging" tests are done to simulate the effects of time on a particular substance (performed pretty much how Al described). The effectiveness and accuracy of these accelerated aging studies is subject for a completely different discussion.
The analogy to milk is a good one. If a carton has an expiration date of January 3rd, the milk inside is not good on the 3rd and magically turns to yogurt on the 4th. I regularly drink milk that is 5-6 days after the expiration as long as it hasn't gone sour. Unfortunately drugs typically do not "go sour" to give you a good indication of when they have turned bad. Aging for most drugs that I have worked with is pretty linear. That means that the compounds break down at a regular rate over time and the potency of the entire pill gradually diminishes. Therefore, a pill taken during the expiration month has virtually the same potency as it would one month after expiration.
There is another component of shelf life that is worth mentioning as well, and that is Marketing. If generic Warfarin had a shelf life of 2 months, and the brand-name Coumadin had a shelf life of 4 years, would anyone buy the generic? Also, what's the benefit for the makers of Coumadin showing that their drug has a shelf life of 5 years instead of 4 years? If you leave it at 4 years, most people will clear out whatever they have when it expires and buy a new bottle. Obviously this results in higher sales of the drug over the long term. All of these things and more are discussed when a company decides the shelf life of a drug.