Link to home
Start Free TrialLog in
Avatar of gok11
gok11

asked on

Add days to a date

I need to add a specific number of days to a date in JQuery. The set Date function is not computing the date correctly.

The number of days (advdays) to add is 45 or 90 or 120 .

var advDate = new Date();
var advdays = $(cntlName).val();

advDate.setDate( advDate.getDate() + advdays)  ;

The computed advDate is never correct.

This needs to be jQuery since this is a part of a larger validation function.

Thank you for the help in advance.
ASKER CERTIFIED SOLUTION
Avatar of chaau
chaau
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gok11
gok11

ASKER

Thank you for the reply.

Using parseInt($(cntlName).val()) solved the issue.
Avatar of gok11

ASKER

I've requested that this question be closed as follows:

Accepted answer: 0 points for gok11's comment #a40116952

for the following reason:

Reply from the expert made me realize that the value must be converted to Int before using it.