add year to a date using javascript

Posted by Klbaiju under ASP.NET on 3/30/2012 | Points: 10 | Views : 4177 | Status : [Member] | Replies : 1
Hi,
in my application there is a text box and enter date in
mm/dd/yyyy format.
eg :- 01/20/2012

on the blur event text box i want to add 1 year to another textfield

ie second textbox should be 01/20/2013

i need the javascript code.


Regards

K L BAIJU




Responses

Posted by: Rajni.Shekhar on: 3/30/2012 [Member] Bronze | Points: 25

Up
0
Down
try this

var dt = "01/20/2012";
var newDt;
var arr = dt.split("/");
newDt = arr[0] + "/" + arr[1] + "/" + (parseInt(arr[2]) + 1);
alert(newDt);

Thanks,
Rajni Shekhar

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response