Back
You can try the below code:
function ChangeDateFormat(date) { var i = new Date(date), month = '' + (i.getMonth() + 1), day = '' + i.getDate(), year = i.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; return [year, month, day].join('-');}alert(ChangeDateFormat('Sun May 11,2014'));console.log(ChangeDateFormat('Sun May 11,2014'));
function ChangeDateFormat(date) {
var i = new Date(date),
month = '' + (i.getMonth() + 1),
day = '' + i.getDate(),
year = i.getFullYear();
if (month.length < 2)
month = '0' + month;
if (day.length < 2)
day = '0' + day;
return [year, month, day].join('-');
}
alert(ChangeDateFormat('Sun May 11,2014'));
console.log(ChangeDateFormat('Sun May 11,2014'));
I hope this will help.
Want to become a Java expert? join Java Certification now!!
31k questions
32.8k answers
501 comments
693 users