I have a date with the format Sun May 11,2014. How can I convert it to 2014-05-11 using JavaScript?
Sun May 11,2014
2014-05-11
A combination of some of the answers:
var d = new Date(date); date = [ d.getFullYear(), ('0' + (d.getMonth() + 1)).slice(-2), ('0' + d.getDate()).slice(-2) ].join('-');