get current time in 24 hour format in javascript code example
Example 1: get the current date time in javascript in 12 hour format
//this will give you date object remove the outer new Date to have
//it as string
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: javascript get 24 hour time
var date = new Date();
console.log(date.toLocaleString('en-GB'));