Wednesday, 19 November 2014

Add one year to date in jquery

// How to add one year to date
$('#startDate').focusout(function(){
         var s =$(this).val().split('/');
         var e = new Date(++s[2], --s[1], --s[0]);
         var date = (e.getDate() < 10) ? ('0'+e.getDate()) : e.getDate();
         var month = ((e.getMonth()+1) < 10) ? ('0'+(e.getMonth()+1)) : (e.getMonth()+1);
              $('#endDate').val(date+"/"+month+"/"+e.getFullYear());
 });

No comments:

Post a Comment