convert hour to am or pm javascript code example
Example 1: how to convert time to am pm in javascript
var suffix = hour >= 12 ? "PM":"AM";
var hours = ((hour + 11) % 12 + 1) + suffix
Example 2: how to conver time format to 12 hours in javascript
var hours = dt.getHours()
minute = dt.getMinutes();
hours = (hours % 12) || 12;
console.log("Time is - " + hours + ":" + minure;