0

I'm having troubles on formating the dates on Jquery UI datapicker.

What I have to do is choose a date on the calendar UI and then I have to calculate some dates based on the date entered. Everything is working except for the date format. Is showing me the FULL date as follows: "Mon Sep 15 2014 00:00:00 GMT+0200 (Hora de verano romance)" and I just want a dd-mm-yy format

check it here http://fiddle.jshell.net/80em5wLd/

<input type="text" name="arrivalDate" class="datepicker">
<input type="" name="auditDate" value="">
<input type="" name="presentationDate" value="">

 $('input[name="arrivalDate"]').datepicker({
 onSelect: function(){
 var start = $('input[name="arrivalDate"]').val();

 var audit= 14;
 var presentation= audit+14;
 var date = new Date(start);
 var d = date.getDate();
 var m = date.getMonth();
 var y = date.getFullYear();
 var date_1= new Date (y, m, d+audit);
 var date_2= new Date(y, m, d+presentation);
 $('input[name="auditDate"]').val(date_1);
 $('input[name="presentationDate"]').val(date_2);
}

});

Thanks!

Mario Sanchez Maselli
  • 1,021
  • 1
  • 12
  • 25
  • possible duplicate of: http://stackoverflow.com/questions/1328025/jquery-ui-datepicker-change-date-format – John Sep 04 '14 at 16:56

2 Answers2

1

Have this a try, date.toLocaleDateString();

Aaron
  • 1,208
  • 1
  • 9
  • 21
0
datepicker({ dateFormat: 'dd-mm-yy' })
Quentin Geff
  • 819
  • 1
  • 6
  • 21