var dateWithTime = new Date().toLocaleString().replace(",", "")
console.log(dateWithTime)
//output :6/24/2022 9:36:33 PM
var d = new Date(),
minutes = d.getMinutes().toString().length == 1 ? '0'+d.getMinutes() : d.getMinutes(),
hours = d.getHours().toString().length == 1 ? '0'+d.getHours() : d.getHours(),
ampm = d.getHours() >= 12 ? 'pm' : 'am',
months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
return days[d.getDay()]+' '+months[d.getMonth()]+' '+d.getDate()+' '+d.getFullYear()+' '+hours+':'+minutes+ampm;
// To test a function and get back its return
function printElapsedTime(fTest) {
let nStartTime = Date.now(),
vReturn = fTest(),
nEndTime = Date.now()
console.log(`Elapsed time: ${ String(nEndTime - nStartTime) } milliseconds`)
return vReturn
}
let yourFunctionReturn = printElapsedTime(yourFunction)