Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
6
rated 0 times [  11] [ 5]  / answers: 1 / hits: 18373  / 14 Years ago, tue, november 16, 2010, 12:00:00

How can I find the date 30 days after the current day? here 30 is the fixed value. how can i pass the dynamic value to this function..



days = document.getElementById('day').value;
var d = new Date();
d.setDate(d.getDate() + days);


it is not working..it gives wrong answer


More From » javascript

 Answers
11

You can access the time in Javascript using the Date class. Try this:



var time = new Date();
time.setDate(time.getDate()+30);
alert(time);


EDIT Just added a test jsFiddle here in case somebody wants to test it.



Sorry I forgot the adding!!!


[#94952] Saturday, November 13, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
valentinam

Total Points: 166
Total Questions: 117
Total Answers: 81

Location: Puerto Rico
Member since Sun, Jun 27, 2021
3 Years ago
;