How to add number of days to today's date? [duplicate]
You can use JavaScript, no jQuery required:
var someDate = new Date();var numberOfDaysToAdd = 6;someDate.setDate(someDate.getDate() + numberOfDaysToAdd);
Formatting to dd/mm/yyyy
:
var dd = someDate.getDate();var mm = someDate.getMonth() + 1;var y = someDate.getFullYear();var someFormattedDate = dd + '/'+ mm + '/'+ y;
This is for 5 days:
var myDate = new Date(new Date().getTime()+(5*24*60*60*1000));
You don't need JQuery, you can do it in JavaScript, Hope you get it.
You could extend the javascript Date object like this
Date.prototype.addDays = function(days) { this.setDate(this.getDate() + parseInt(days)); return this;};
and in your javascript code you could call
var currentDate = new Date();// to add 4 days to current datecurrentDate.addDays(4);