get time from date javascript in 12 hour format code example
Example 1: get the current date time in javascript in 12 hour format
const today = new Date(new Date().toLocaleString("en-US", {
day: '2-digit',
month: '2-digit',
year: 'numeric',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: true
}));
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;