const date = new Date().toLocaleDateString()
console.log(date)
// Output
// 5/23/2022 -> mm/dd/yyyy
const dateArray = date.split("/")
const dateArray.map(d => d.length == 1 && d.length != 4 ? "0"+d : d)
const formatedDate = `${day}.${dateArray[0]}.${dateArray[2]}`
console.log(formatedDate)
// Output
// 23.05.2022 -> dd.mm.yyyy