AM and PM are used in the measurement of time with a 12 hour clock. AM refers to the early half of the day, midnight till noon and PM refers to the latter half of the day, from noon to midnight.
AM is short for the Latin ante meridiem (before mid-day) and PM is short for post meridiem (after mid-day).
The 12 hour clock was developed during the time between the mid second century BC and the 16th century AD, that's a long time to catch on but it did, most places in the world now use the 12 hour clock.