I am trying to convert my dashed date 2013-12-11 to 2013/12/11 using the following function:
function convertDate(stringdate)
{
// Internet Explorer does not
Your function is working as expected convertDate(myDate) is returning the / value off the date.
Your problem seems to be your logging
var myDate = '2013-12-11';
console.log('Before', myDate); //2013-12-11
convertDate(myDate);
console.log('After', myDate); //2013-12-11
Your function returns a value so convertDate(myDate) is just returning and doing nothing. And your console log for after is just returning the same date as before.
If you change your console log to
console.log('After', convertDate(myDate)); //2013-12-11
You will get the expected result, or set myDate to the new value
myDate = convertDate(myDate);
console.log('After', myDate); //2013-12-11
I'm not sure if I misunderstand the question; why not just this:
function convertDate(stringdate)
{
stringdate = stringdate.replace(/-/g, "/");
return stringdate;
}
Use String Replace to replace the dashes with slashes.
string.replace(/-/g,"/")