I have an array of dates (strings) in multiple formats and I want to format them as DD/MM/YYYY with Date constructor but it recognizes the first date in the array in MM/DD/YYYY format. Also, I can split and change places between the first two elements in the map function but then I won't need that for the second date in the array. I also tried moment.js but couldn't find the solution there either.
const dateArr = ['19. Juli 2020', '11.07.20', '11.05.2022', '12.08.2011.', '12.06.2003.'];
const formatedDateArr = docDates.map(date => new Date(date).toDateString());
const result = arr.map(el => moment(el, 'DD/MM/YYY'))
Can someone provide a solution?
Thanks!