JSFiddle - React, Tailwind, and code Playground

by Sagar Bendale

JavaScript

function formatDate(dates) {
var t=[];
dates.map(function(date){
var temp = date.split(' ');
temp[0] = temp[0].replace(/[^0-9]/g,''); 
date = temp.join(' ');
console.log(date)
 var d = new Date(date),
        month = '' + (d.getMonth() + 1),
        day = '' + d.getDate(),
        year = d.getFullYear();

    if (month.length < 2) month = '0' + month;
    if (day.length < 2) day = '0' + day;
    t.push([year, month, day].join('-'));
});
    return t;
}
var dates = ['20th Oct 2014','2 Oct 2034']
 console.log(formatDate(dates));