Yes, it is customary to have dinner between 10 PM and midnight in Spain. However, there are many tourist restaurants where you can eat as early as 6 PM if you would like. If you are so concerned about being mugged, why don't you take a taxi to and from the restaurant?