Date methods allow you to get and set the year, month, day, hour, minute, second, and millisecond of date objects, using either what time zone is it.
to convert date to any desired form use Use the getDate(), getMonth() and getFullYear() javascript built in methods
function setDateFormat(date = new Date()) {
let newDate = (date.getDate()).toString().padStart(2, '0');
newDate = newDate + "-" + (date.getMonth()).toString().padStart(2, '0');
newDate = newDate + "-" + + (date.getFullYear()).toString().padStart(2, '0');
return newDate ;
}