I want to convert dd/mm/yyyy to mm/dd/yyyy in javascript.
Try this example where a regular expression is used to find and switch the parts of the string:
var d1 = "03/25/2011";
var d2 = d1.replace(/^(\d{1,2}\/)(\d{1,2}\/)(\d{4})$/,"$2$1$3");
alert("d1:"+d1 +"\n d2:"+d2 )
/*
// OUTPUT
d1: 03/25/2011
d2: 25/03/2011
*/
EDIT:
I noticed that no other answer is using regular expression and I really wonder why... :)