/* Here is a small general 24hr ->12hr AM/PM function. Paste this function at the top of jquery.showinfo.js, just under the Airtime API version, or at the top of whatever javascript widget you are using. Use it wherever you need to change the time format. See it working here: http://www.deprogrammedradio.com/
It takes standard javascript date objects. Usage example: var SchedStartAMPM = formatTimeAMPM(SchedStartTime); var SchedEndAMPM = formatTimeAMPM(SchedEndTime);
*/
function formatTimeAMPM(date) { function pad(n) { return (n < 10) ? '0' + n : n; } var time = new Date(date); var hours = time.getHours(); var minutes = time.getMinutes(); var ext ='am'; if (hours >= 12) { hours -= 12; ext ='pm'; } if (hours === 0) { hours = 12; } return hours + ':' + pad(minutes) + ext; }
Post edited by John Chewter at 2014-06-28 12:30:56