get hour minutes and am pm from date js code example
Example 1: js get time in am
var time = new Date();
console.log(
time.toLocaleString('en-US', { hour: 'numeric', hour12: true })
);
Example 2: js date remove am and pm
var ampm = hours >= 12 ? 'pm' : 'am';