Home » » Jquery for adding 1 year to the selected dateJquery for adding 1 year to the selected date?

Jquery for adding 1 year to the selected dateJquery for adding 1 year to the selected date?

Written By M.L on செவ்வாய், 15 நவம்பர், 2011 | நவம்பர் 15, 2011

Can someone please help with the Jquery to populate "TODATE" if the "FROMDATE" is selected using calender adding exactly 1 year?
eg
if the TODATE selected is 1/1/2011 then FROMDATE must be 31/12/2011(
if the TODATE selected is 1/3/2011 then FROMDATE must be 29/2/2012 (leap year + month last day consideration)
if the TODATE selected is 1/3/2012 then FROMDATE must be 28/02/2013
ANSWER :

Please try with following (I have taken as from date as current date)
var lastdate = new Date();
lastdate.setYear(lastdate.getYear() + 1);
lastdate.setDate(lastdate.getDate() - 1);

0 comments:

கருத்துரையிடுக

Popular Posts

General Category