First of all, do you know what these words "朝(asa)" ,"昼(hiru)" ,"夕方(yuugata)", "夜,晩(yoru,ban)" and "夜中(yonaka)" mean?
(A)朝 means the period of time from 4 a.m to 10 a.m.
(B)昼 means the period of time from 11 a.m. to 3 p.m.
(C)夕方 means the period of time from 4 p.m. to 6 p.m.
(D)夜 and 晩 mean the period of time from 7 p.m. to 11 p.m.
(E)夜中 means the period of time from 12 a.m. to 3 a.m.
These expressions/explanations depend on the person.
For example
Some people might call 3 a.m. "朝" or use other expressions like "早朝".
Some people might call 6 p.m. 夜.
Some people might use 深夜 instead of 夜中.
My point is to tell you about interesting greetings.
If you have been studying Japanese, you have already learned these phrases "おはよう/おはようございます", "こんにちは", "こんばんは."
When I see someone in (A), I would say おはようございます/おはよう.
When I see someone in (B), I would say こんにちは.
When I see someone in (C), (D) or (E), I would say こんばんは, but I would say "おはようございます" at 3 a.m. It depends on the situation or the person.
I have said おはようございます/おはよう to my family, my friends and coworkers, but I have never said こんにちは and こんばんは to my family and I almost never say "こんにちは" or "こんばんは" to my friends and my coworkers.
Why? I'm not sure. lol
This is my feeling. When I say おはよう to my friends, the situation is as usual, but when I say こんにちは/こんばんは to them, I feel like they are not my friends.
Some people who work at night might say おはようございます/おはよう to someone at night.