I'm using datepicker to set the end date to be 6 months after the start date. What I have is working except in edge cases. Example. If start date is 31-Mar-2014 then the end date should be 30-Sep-2014. However I get 01-Oct-2014. I've read about this being a known issue in other thread comments Here and Here.
Is there something in JQuery or datepicker or an easy way that I can correct the date in edge cases like this?
There is likely an answer to this already but I haven't been able to scout it out. Any help would be greatly appreciated.
Here is the stripped down code and a demo I made that shows the example.
$("#StartDate").datepicker({
    changeMonth: true,
    changeYear: true,
    dateFormat: "dd-M-yy",
    onSelect: function () {
        autoFillEndDate(); 
        }
 });
 $("#EndDate").datepicker({
     changeMonth: true,
     changeYear: true,
     dateFormat: "dd-M-yy"
 });
function autoFillEndDate() {
    if ($('#StartDate').val().length !== 0) {
        var offset;
        var offsetType;
        var StartDate = $('#StartDate').datepicker('getDate');
        var newDate = StartDate.setMonth(StartDate.getMonth() + 6);
        var EndDT = $.datepicker.formatDate('dd-M-yy', new Date(newDate));
        $('#EndDate').datepicker("setDate",EndDT);
    }
}
 
     
    