There is no single rule concerning how to shorten "ante meridiem" or "post meridiem," so "A.M." and "P.M." are not required to be capitalized when writing time. The abbreviations "A.M.," "a.m.," "P.M." and "p.m." are all correct. In many cases, the abbreviation that is selected depends upon the style guide used.
For daily purposes, a writer goes with personal preference because either capital or lowercase letters with periods are acceptable. However, in educational or professional situations, a specific format is often required, and its rules for abbreviations should be followed. In MLA format, lower case letters are followed by periods. No space is allowed between the letters, so MLA uses "a.m." APA style also requires lower case with periods because a.m. and p.m. are abbreviations of Latin words.