// Convert Date.now() to Formatted Date in "dd-MM-YYYY".
function convertDate(inputFormat) {
function pad(s) { return (s < 10) ? '0' + s : s; }
var d = new Date(inputFormat)
return [pad(d.getDate()), pad(d.getMonth()+1), d.getFullYear()].join('-')
}
console.log(convertDate('Mon Nov 19 13:29:40 2012')) // => "19-11-2012"
const str = '22/04/2022';
const [day, month, year] = str.split('/');
console.log(day); // 22
console.log(month); // 04
console.log(year); // 2022
const date = new Date(+year, month - 1, +day);
console.log(date); // Fri Apr 22 2022