"Good night" or "good evening"?
Depends on context. "Good night" is generally reserved as a replacement for "goodbye". "Good evening" is a form of "hello".
"Good evening" is something that can be used from roughly 5 PM on. "Good night" can also be said from 5 PM on, but usually means one of two things:
"goodbye (for the rest of the day, because we are leaving work, the bar, etc.)"
"I'm going to bed now and/or "you're going to bed now" (said to family members, people I am chatting with online or on the phone, when one or both of us is going to bed)"
It basically never means "hello (late evening)" that equivalent phrases can have in other languages.
My answer from a similar, before someone pointed to this as a related question, to which this is even more suited:
"Good night" as a greeting was once commonly found in Ireland, but almost exclusive to there. In James Joyce's "The Dead", for example, it is used both as greeting:
—O, Mr Conroy, said Lily to Gabriel when she opened the door for him, Miss Kate and Miss Julia thought you were never coming. Good night, Mrs Conroy.
And as a farewell:
—Well, good night, Aunt Kate, and thanks for the pleasant evening.
I suspect, but do not know for sure, that this was a retention of something that was more widespread, but died out elsewhere sooner than in Ireland.
In any case, it has mostly died out here too. It may be heard from an older generation, and perhaps lingers in some regions, but my generation (mid 30s) wouldn't use it either in the region I grew up, nor where I now live.
"Good evening" would be the more normal night-time greeting.
The only logical explanation I can think of for our no longer using "good night" in this way, is that it is so often said to someone about to retire to bed, that it was hence used more often as a farewell and then came to have only this meaning. The other forms, after all, would be more often used as a greeting than a farewell, though historically that was not the case.
So far as I know, there is no generally accepted definition of the exact times that evening starts and ends.
As others have said, good night is most often used when parting. If you said this at 7:30 people might respond "goodbye" and turn away.
As you enter the home of a friend, you might say good night to someone leaving and good evening to your host (assuming it isn't the sort of occasion where "wassup hussler" and "yo bitch" are appropriate).