At different times of day you greet people with different greetings. In the morning it is good morning in the afternoon it’s good afternoon at night or in the evening good evening or good night. It is the same in Spanish. Instead of a simple hola; say Buenos diás in the morning buenas tardes in the afternoon and buenas noches in the evening or night.
Here is  a video on How to greet people at different times of day.

Here it is