Beer is extremely sensitive to sunlight and heat. If your talking about amber bottles, they can take a couple of hours of sunlight before the beer goes bad. Green bottles about 20 to 30 minutes and clear bottles almost nothing. When exposed to sunlight, some hop compounds change and beer gets an off-flavor that’s called Lightstruck, also referred to as skunk. It gets a cardboardy taste that is very unpleasant and spoils the beer.
Kegs and cans are resistant to light, but heat is bad for all packaging types. If you consider that breweries perform a “forced aging test” that involves heating beer to 40ºC for about a day (which is not very hot, since trucks in the sun can get way hotter than that) and shaking it for another day so that they age a year in a very small timeframe, you can see that heat and shaking are bad for beer.
The best possible beers are fresh tasting ones. To keep them that way, store them as cool as possible (0–5ºC is the optimal range) and they’ll last a long time.