The day before or a few days before or even the day of can work. I make a fair amount of spontaneous trips since I only live a two-hour drive away, and recently I got a Le Cellier lunch the day before. I've seen Ohana and California Grill and other popular places open the day before too, and not at horrible times (I personally would call 10pm a horrible time, that's much too late for me), but normal times.
I decided last Saturday to go to Magic Kingdom the day of, and online there were openings for Crystal Palace, Liberty Tree, and one other place (not many openings, just one or two for each). When I got there, LTT was taking walk-ups, but the Plaza was completely booked (it was a pretty busy day).
So yeah, really it just varies. As long as you're diligent about checking, you should be able to find some decent meals.