Format date hours and minute to AM or PM in Javasript.
function formatAmPm(dateStr) {
const date = new Date(dateStr);
const ampm = date.getHours() >= 12 ? 'PM' : 'AM';
return `${date.getHours()}:${date.getMinutes()} ${ampm}`
}
Usage :
formatAmPm('2022-11-24T06:28:29.409Z')// '13:28 PM'