By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,297 Members | 697 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,297 IT Pros & Developers. It's quick & easy.

How can I calculate date plus or minus n days

P: 2
I have n days and a date, I want a date plus(or minus) to n days.How can I do that in javascript
May 10 '07 #1
Share this Question
Share on Google+
4 Replies

dmjpro
100+
P: 2,476
Welcome to TSDN.............

have a look on ............ http://www.w3schools.com/jsref/jsref_obj_date.asp

then try ..............
Expand|Select|Wrap|Line Numbers
  1. Date D = new Date();
  2. D.setDate(D.getDate()+33)
best of luck.
kind regards.
May 10 '07 #2

P: 2
Thank you very much

I have another solution :
Expand|Select|Wrap|Line Numbers
  1. Date.prototype.addDays =
  2.          function(days)
  3.          {
  4.             return new Date(this.getTime() + days * 24 * 60 * 60 * 1000);
  5.          }
Best regrad
May 10 '07 #3

dmjpro
100+
P: 2,476
good to see you r handling the JS inheritence properties.....

best of luck with ur talent.
kind regards.
May 10 '07 #4

P: 1
@tamnguyet
Your solution fixed my searching to end, it fulfilled my search
Mar 11 '15 #5

Post your reply

Sign in to post your reply or Sign up for a free account.