Currently we have multiple date formats in our database:
DD/MM/YYYY
DD-MM-YYYY
YYYY/MM/DD
YYYY-MM-DD
We all want to format these to one format YYYY-MM-DD. When using dayjs to do this I'm getting NaN-NaN-NaN back when running dayjs('14/05/1993').format('YYYY-MM-DD')
We can add a format to dayjs by adding the customParseFormat plugin
dayjs.extend(customParseFormat)
dayjs('14/05/1993', 'DD/MM/YYYY').format('YYYY-MM-DD')
But how can we detect the format for all four formats we have?
(Solution may be without dayjs)