JQuery add month to selected date

We have 1 month, 3 months, 6 months, 9 months, 1 year Membership in the drop-down list

What we are trying to do is if the user chooses on 06/25/2012 to start membership in 9 months, we want to show him when his membership expires, for example, 03/25/2013. we tried a lot of things but gave the wrong date.

we use jquery-ui to select a membership start date

Relations Arshad

+4
source share
3 answers

I like date.js , it is a small library convenient for this type of thing.

+4
source
var date1 = new Date(); date1 .setMonth(date1 .getMonth() - 12); 

now date1 is an object with a date 12 months ago

If you want to set it in jQuery UI DatePickers, you can do it

  $("#txtToDate").datepicker("setDate", new Date()); $("#txtFromDate").datepicker("setDate", date1 ); 
+4
source

Try the following:

 var s = $("#inputid"); var d= $.datepicker.parseDate(datepickeroption.dateFormat, s) d.setMonth( d.getMonth( ) + 1 ); 
0
source

Source: https://habr.com/ru/post/1397631/


All Articles