thu jun 09 2011 to YYYY-MM-DD
function convert(str) {
var mnths = {
Jan: "01",
Feb: "02",
Mar: "03",
Apr: "04",
May: "05",
Jun: "06",
Jul: "07",
Aug: "08",
Sep: "09",
Oct: "10",
Nov: "11",
Dec: "12"
},
date = str.split(" ");
return [date[3], mnths[date[1]], date[2]].join("-");
}
console.log(convert("Thu Jun 09 2011 00:00:00 GMT+0530 (India Standard Time)"))
//-> "2011-06-09"
Run code snippet