This variant adds the symetric YYY-mmm-dd, allows for single digit day numbers and provides for the specification of the month names for language independence.
function parseDate (date, months) {
var dateRE = /^(?:(\d\d?)-(%m)-(\d{4})|(%m)-(\d\d?)-(\d{4})|(\d{4})-(%m)-(\d\d?))$/;
if (!months)
months = 'jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec';
dateRE = RegExp (('' + dateRE).replace (/%m/g, months).slice (1, -1), 'i');
date = date.match (dateRE) || [date];
return date.length == 1 ?
date[0] : // Return string if parse error
[date[1] || date[4] || date[7], date[2] || date[5] || date[8], date[3] || date[6]|| date[9]];
}
console.log (parseDate ("13-feb-2014"));
console.log (parseDate ("Feb-13-2014"));
console.log (parseDate ("2014-FEB-13"));
console.log (parseDate ("1-feb-2014"));
console.log (parseDate ("Feb-1-2014"));
console.log (parseDate ("2014-FEB-1"));
console.log (parseDate ("01-fev-678"));
Displays
["13", "feb", "2014"]
["Feb", "13", "2014"]
["2014", "FEB", "13"]
["1", "feb", "2014"]
["Feb", "1", "2014"]
["2014", "FEB", "1"]
"01-fev-678"