1var time = new Date();
2console.log(
3 time.toLocaleString('en-US', { hour: 'numeric', hour12: true })
4);
1//this will give you date object remove the outer new Date to have
2//it as string
3const today = new Date(new Date().toLocaleString("en-US", {
4 day: '2-digit',
5 month: '2-digit',
6 year: 'numeric',
7 hour: '2-digit',
8 minute: '2-digit',
9 second: '2-digit',
10 hour12: true
11}));