function myYmd(D){
var pad = function(num) {
var s = '0' + num;
return s.substr(s.length - 2);
}
var Result = D.getFullYear() + '-' + pad((D.getMonth() + 1)) + '-' + pad(D.getDate());
return Result;
}
var datemilli = new Date('Sun May 11,2014');
document.write(myYmd(datemilli));