SOURCE

function reformatDate(date: string): string {
    const validate = (day)=>{
        return day<10?"0"+day:day;
    }
    const day = ["1st","2nd","3rd","4"];
    const mon = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
    const [nDay,nMon,nYear] = date.split(" ")
    console.log(nDay);
    const retMon = validate(mon.indexOf(nMon))
    console.log(validate(retMon));
    console.log(nMon);
    console.log(`${nYear}-${retMon}-${nDay}`);
};

reformatDate("26th May 1960");
console 命令行工具 X clear

                    
>
console