I have attempted the following code in order to convert the date from 'yyyy-mm-dd' format to 'dd/MM/yyyy'. However, when I check the typeof() of the result, it shows that it is a string. Is there a method to convert it into only a date?
let convertedDate;
const timestamp = Date.parse(myStringDate);
if (isNaN(timestamp) === false) {
const newdate = new Date(myStringDate);
convertedDate = `${newdate.getDate()}/${newdate.getMonth()+1}/${newdate.getFullYear()}`
return convertedDate;
} else {
return myStringDate;
}