In one word, p.m. means “post meridiem”, which means “after noon” in Latin, but a.m. means “ante meridiem”, which means “before noon” in Latin.
As everyone knows, nowadays majority of clocks are 12-hour clocks. 12-hour clocks divide 24 hours in a day, which in turn is divided into two 12-hour periods. Period “ante meridiem”, which, as said before, means “before noon”, applies on period between midnight, which is 0:00, and noon, which is 12:00. Period “post meridiem”, which, as said before, means “after noon”, applies on period between noon, which is 12:00, and midnight, which is 0:00. This is why every hour of the day, except midnight (0:00) and noon (12:00), is suffixed by p.m. or a.m. to identify whether the certain hour is in the morning, afternoon or evening.
24-hour clock usually displays the number of hours which are passed since midnight. For example, 19:00 hours on a 24-hour clock on 7th of May means, that 19:00 hours are passed since midnight of 7th of May. Interesting, that format of 24-hour time is sometimes known as military time. The 24-hour clock is used in several specialist areas, for example, military, aviation, navigation, astronomy, meteorology, emergency services, hospitals, computing, logistics, tourism and other areas, where 12-hour clock is deemed too inconvenient, burdensome or even dangerous.
It is believed, that Egyptians are responsible for dividing the day into 24 equal parts. One source considers that this is because they used the base 12, but other source considers that this is because they used system of 36 groups of stars, which were known as decans and which told time at night.
Often people get confused, because they do not know, whether to use 12 p.m. or noon. Actually it does not make sense to use a compound “12 p.m.”, since it is not after noon. Also it does not make sense to use a compound “12 a.m.”, since it is not before noon. To avoid any confusions it is recommended to call these hours as noon and midnight. It should be mentioned, that majority of digital clocks show 12 p.m. and 12 a.m. to identify, whether it is noon or midnight.
Now let’s talk about midnight. Some people get confused, when they are asked to pick up their friend at the airport at midnight of May 7, because they do not know, whether they have to pick up their friend at the beginning of May 7 or at the end of May 7. When people say “midnight”, it is confusing, because it is unclear, whether they mean the midnight at the beginning of the day or the midnight at the end of the day. It is because midnight is the time, when the date changes from the previous to the next. One solution of this problem is to say 12:01 a.m., May 7 or 11:59 p.m. May 7. Other solution of this problem is to use the 24-hour clock format. For example, if your friend asks to be at the airport at 00:00 on May 7, you should be there at the beginning of May 7, but if it asks to be at 24:00 on May 7, you should be there at the end of May 7.