It is often said that 12 am (or 00:00) refers to midnight at the start of the specified day and 12 pm is mid-day, with midnight at the end of that day being 24:00.
There are no official standards established for the meaning of 12 am and 12 pm. Technically, it is actually incorrect to use “am” and “pm” when referring to noon (12:00). The abbreviation am stands for ante meridiem (before noon) and pm stands for post meridiem (after noon). Since noon is neither after noon nor before noon, and midnight can equally be twelve hours before and after noon, neither abbreviation is correct. Given this ambiguity, the terms 12 am and 12 pm should be avoided.
In context, it is generally easy to determine what someone is referring to when talking about midnight on a certain day, e.g. when someone refers to “midnight last night” or “midnight tonight”. The problem arises when a date/time is referred to as “midnight on Friday, November 5th”.
The best way to avoid confusion is to use the 24-hour clock – where 12:00 is 12 noon and 24:00 Sunday or 00:00 Monday both mean midnight Sunday/Monday. It is common in transport timetables to use 23:59 Sunday or 00:01 Monday, to further reduce confusion.