you should usually eat something packed with protein within 30 minutes of your workout, nothing too filling though, maybe some almonds or peanut butter, and then eat something else within an hour after you finish your workout
Eat at least 2 hours before you work out. You don't want to work out with food in your tummy. That would cause your digestive system to shut down while the rest of you is ramped up due to exercise stress.
You can eat anytime after your workout. Taking in protein 20 to 45 minutes after weight bearing exercises is a great idea if you are trying to build muscle.