0

Want to convert the date format which is like 16-Mar-2016 to 2016-03-16 in jquery

var requestStartDate = new Date(Date.parse(16-Mar-2016)).format("yyyy-MM-dd");

I tried with the above code, it is not working.

Cœur
  • 32,421
  • 21
  • 173
  • 232
  • $("#testDate").val($.datepicker.formatDate('yyyy-MM-dd', requestDate)); if using jquery UI – Max Mar 23 '18 at 06:44
  • Why do you need to do it in jQuery and not just in vanilla JavaScript? – Magnus Eriksson Mar 23 '18 at 06:48
  • You should take a look at the accepted answer here: https://stackoverflow.com/questions/23593052/format-javascript-date-to-yyyy-mm-dd/29774197 and then use `formatDate(Date.parse("16-Mar-2016"))` – ReGdYN Mar 23 '18 at 06:56
  • is it possible to store the converted date format in variable, the above code is like binding the converted value in input field. – S Mugunthan kumar Mar 23 '18 at 06:56
  • @SMugunthankumar Directly call the function and store it in a variable var y = formatDate("2016-03-16"); alert(y); – Nawaz Ghori Mar 23 '18 at 07:10

0 Answers0