As you get up in the morning, stretch yourself and
try to find your way into the new day, you'll be
greeted by "buenos días" by those who you meet.
As the day goes on you'll find that the greeting
changes to "buenas tardes" and at some point in
the evening this changes to "buenas noches".
But when exactly do you change the greeting?
The answer is simple: before lunch time, you use the
"buenos días" greeting. After lunch time but before
dinner you use "buenas tardes" and after dinner you
switch to "buenas noches".
So it is not the exact time (as before or after
midday) but when you and the locals have eaten that
determines the greeting!