Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

am pm after the time in html

var inputEle = document.getElementById('timeInput');


function onTimeChange() {
  var timeSplit = inputEle.value.split(':'),
    hours,
    minutes,
    meridian;
  hours = timeSplit[0];
  minutes = timeSplit[1];
  if (hours > 12) {
    meridian = 'PM';
    hours -= 12;
  } else if (hours < 12) {
    meridian = 'AM';
    if (hours == 0) {
      hours = 12;
    }
  } else {
    meridian = 'PM';
  }
  alert(hours + ':' + minutes + ' ' + meridian);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pm #time #html
ADD COMMENT
Topic
Name
1+8 =