jsFiddle Demo
Separate the string based on spaces. Take the parts and repair them.
function convertDate(d){ var parts = d.split(" "); var months = {Jan: "01",Feb: "02",Mar: "03",Apr: "04",May: "05",Jun: "06",Jul: "07",Aug: "08",Sep: "09",Oct: "10",Nov: "11",Dec: "12"}; return parts[3]+"-"+months[parts[1]]+"-"+parts[2]; } var d = "Fri Jan 31 2014 00:00:00 GMT-0800 (Pacific Standard Time)"; alert(convertDate(d));
source share