function format24Time(time24hour) {
if (time24hour.toString()=='0000') { return "12:00am" }
// converts a 24-hour time (hhmm) to 12-hour time (hh:mm a/p)
if (time24hour.toString().length === 3) {
// in case leading zero isn't there for the hour
time24hour = '0' + time24hour;
}
var hour = parseInt(time24hour.toString().substring(0,2), 10);
var minute = time24hour.toString().substring(2,4);
var meridian = 'am';
if(hour > 12) {
hour -= 12;
meridian = 'pm';
}
var returnTime = hour.toString();
returnTime += ':' + minute;
returnTime += meridian;
return returnTime;
}