score:0

Accepted answer

JS month range is from 0-11. So you have to add 1 to month.

const formatingDate = (dates) => {
    const d = new Date(dates);
    return `${(d.getMonth() + 1)
        .toString()
        .padStart(2, '0')}/${d
        .getDate()
        .toString()
        .padStart(2, '0')}/${d.getFullYear()}`;
};

console.log(formatingDate('2019-07-24'))

Reference.

score:2

Please refer to this document

getMonth

Months are from 0 to n-1


Related Query

More Query from same tag