am pm date format javascript 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';