I want to convert dd/mm/yyyy to mm/dd/yyyy in javascript.
use this function
function dateFormat(existingFormat,neededFormat,existingSeperator,newSeperator,dateValue)
{
var exst = existingFormat.toLowerCase().split(existingSeperator);
var d = dateValue.split(existingSeperator);
d[exst[0]] = d[0]; d[exst[1]]=d[1]; d[exst[2]]=d[2];
var newst = neededFormat.toLowerCase().split(existingSeperator);
newDate = d[newst[0]] +newSeperator+d[newst[1]] +newSeperator+d[newst[2]];
return(newDate);
}
var dd = dateFormat('dd/yy/mm','mm/dd/yy','/','-','30/87/05');//dateFormat(existingFormat,neededFormat,existingSeperator,newSeperator,dateValue)
//use same name for date month and year in both formats
You can use this function for converting any format date(including month date year only) to any format. :)