I think something to consider is that saying "Good afternoon" is not always appropriate. I don't mean "wrong" and I don't mean in terms of time. Rather, I think "greetings", in general, are in question here. What I might do when speaking Japanese, instead of saying こんにちは, is ask お元気ですか? or something similar (and within terms of appropriate politeness).
So, in essence, don't get stuck thinking that you have to greet someone based on what time it is, etc. Think in terms of your relationship with the individual(s) you are speaking with and the context within which you are doing it.
For example, it may be 2:00 in the afternoon, but you haven't seen or spoken with your teacher Mr. Tanaka in about a year, so instead of 田中先生、こんにちは, you would say 田中先生、久しぶりですね!(hisashiburi desu ne! "It's been awhile!").
Hope this helps.