See this wikipedia page
It could be not to difficult to make tests to subtract 12 (and add a.m. or p.m.) when necessary...
Use a var hm='hh:mm'.split(':') to get the hours (hrs=parsInt(hm,10); to remove the leading zero) and minutes (mns=hm).
Then there is only to substract 12 if the hours are greater than 12, and to add (with a second test) a suffix ' a.m.' or ' p.m.' if the hours are less than 12.
EDIT : Midnight are still particular cases. They can be treated by replacing the strings obtained (00:00 a.m.) by appropriate string (12:00 p.m.) with the replace method.