Just like on people food you should be able to find a date on the bag. All the foods I feed my dogs have dates on them. I have feed my dogs food after the date(not on purpose) and didnt have any problems. It was only a month after the date though.
It depends on the food. The lower quality foods last a good long time, higher quality foods not nearly as long. There should be a "best by" or "good until" date on the bag, if not you can e-mail your UPC code to the manufacturer and they can tell you.
Personally I go through a bag every 3 weeks so I've never had to worry about it spoiling.