I have a Javascript in which I need to paste the current time in a format HH:MM AM/PM. There\'s one catch - I need to put the time that starts in two hours from now, so for
Simply, you can do this
const date = new Date() const options = { hour: 'numeric', minute: 'numeric', hour12: true }; const time = new Intl.DateTimeFormat('en-US', options).format(date) console.log(time)
For more details, you can refer to the MDN docs regarding the same.