"Guten Tag" is the normal way of greeting a person when you meet her. It is completely independent of the time of the day. It is used especially in the northern part of the German-speaking area wheras in the southern part "Grüß Gott" is more common.
"Guten Morgen" however may be used only in the morning (until 10am at most I would say). When used later in the day "Guten Morgen" could be understood in an ironical sense (implying that the person you are talking to is not yet awake). So be carefull!
In the evening you may say "Guten Abend" when you meet someone and "Gute Nacht" to say goodbye. You do NOT say "Guten Nachmittag" in German!
In earlier times "guten Tag" was also used to say goodbye and especially to tell a person that you want to put an end to the conversation. This is obsolete today but you may find it in literature.
Of course today there are also a lot of other forms of greating like "Hallo", "Hi", "Ciao", "Servus" and so on.