0

I am using the default for a date field in a form and this outputs a value of "YYYY-MM-DD" however for the query I am running with the form I need the format "YYYY,MM,DD".

Is there an easy way with javascript to parse this input fields value to fit the second format?

Thank you.

Jay
  • 23
  • 5
  • So all you need to do is replace the dashes with commas. That should be easy enough to research. – CBroe Oct 06 '15 at 19:18

2 Answers2

1

If you parse it with javascript before you submit it, yes. Working fiddle: http://jsfiddle.net/gasm6d0e/

HTML:

<input type="date" id="bday" value="2010-10-01">

Javascript/JQuery

alert($("#bday").val().replace(/-/g,","));
Rick Burns
  • 1,538
  • 16
  • 20
1

I figured out how to parse it using the substr function:

function reorder_date(string)
    {   
    year = string.substr(0,4);
    month = string.substr(5,2);
    day = string.substr(8,2);
    next_string= year + "," + month + "," + day;
    return next_string;
    }
Jay
  • 23
  • 5