The core part of the sentence is 時間がある, which in this context basically means you are free. That free time lasts until the train leaves and it can be utilized for eating something.
電車が出る前に何か食べる時間がある is not wrong but it sounds like you are stating there is snack time planned before the departure of the train on an itinerary or something. 〜前に is used to talk about the occurrence of some event before another event. The focus is on the relative positions of two points on the timeline.
ある in your sentence doesn't match this punctual image. It translates more to a line segment on the timeline and まで puts focus on the end of it.