What you eat before and after you exercise makes a big difference in your performance and recovery, especially if you're an athlete. This training diet from the Iowa State University suggests carb-rich meals before, light snacks during, and fluid replacement after exercising.
The sports nutrition article states that it's not just the pre-exercise meal alone but the meals you eat in the 2-3 days before you exercise that fuel your muscles. So it's important to eat high-energy meals a couple of days before serious training or an event (track meet or basketball game, for example).
Although what you should eat would vary by the kind of exercise or activity you're doing — and how intensely — the cornerstone of an athlete's diet is carbohydrates. Avoid high fat and protein, since they won't provide energy for your exercise.
As to when you should eat specific foods, the general guidelines are to eat a solid meal four hours before exercising or a liquid meal 2-3 hours before. Within 1-2 hours before exercise, try a high carb/energy drink or fluid replacement drink. If you have less than an hour before activity, just have water or a fluid replacement drink.
During an event, go for water, and don't bother with energy drinks — they don't increase performance for exercises under 90 minutes.
After you exercise, get some carbs (from fruits, sports drinks, smoothies, juices, etc) within 15 minutes to restore glycogen. Within two hours of exercise, go for a carbohydrate-rich meal. This recommendation fits well with one we've previously seen about low-carb meals being great post-workout.
Check out the full article via the link below for more exercise meal guidelines, some notes on nutritional drinks, and more sports nutrition.
Training Diet [Iowa State University - University Extension]
This story has been updated since its original publication.