This question already has an answer here:
- Add days to JavaScript Date 37 answers
I need to be able to add 1, 2 , 5 or 10 days to today's date using jQuery.
This question already has an answer here:
I need to be able to add 1, 2 , 5 or 10 days to today's date using jQuery.
You could extend the javascript Date object like this
and in your javascript code you could call
If the times in the Date are not needed, then you can simply use the date object's methods to extract the Month,Year and Day and add "n" number of days to the Day part.
Ref:Mozilla Javascript GetDate
Edit: Ref: Mozilla JavaScript Date
The prototype-solution from Krishna Chytanya is very nice, but needs a minor but important improvement. The days param must be parsed as Integer to avoid weird calculations when days is a String like "1". (I needed several hours to find out, what went wrong in my application.)
Even if you do not use this prototype function: Always be sure to have an Integer when using setDate().
you can try this and don't need JQuery: timeSolver.js
For example, add 5 day on today:
You also can add by hour, month...etc. please see for more infomation.