const getDate = (date) => {
let currentMonth = date.getMonth() + 1;
let currentDay = date.getDate();
if (currentDay < 10) {
currentDay = “0” + currentDay;
}
if (currentMonth < 10) {
currentMonth = “0” + currentMonth;
}
const currentYear = date.getFullYear();
return currentDay + ‘-‘ + currentMonth + ‘-‘ + currentYear;
}
getDate(new Date());
//output
08-05-2022