sayedsohail Posted October 8, 2007 Share Posted October 8, 2007 Hi everyone, I got a form with to fields, Signdate=today which is fine expire date = signdate+6months How do i achieve add six months to signdate. Please help. Link to comment https://forums.phpfreaks.com/topic/72327-solved-add-just-six-months-to-a-given-date/ Share on other sites More sharing options...
sayedsohail Posted October 8, 2007 Author Share Posted October 8, 2007 This is so far i tried, but no success. Date.prototype.addMonths = function(m) { // Adds the number of months to date. this.setMonth(this.getMonth() + m); }; // number of months: var n = getElementById('howmanymonths').value; var selectdate = document.getElementById('signdate'); expiredate.addMonths(n); // set expire date : document.getElementById('expiredate').value= expiredate; Link to comment https://forums.phpfreaks.com/topic/72327-solved-add-just-six-months-to-a-given-date/#findComment-364717 Share on other sites More sharing options...
sayedsohail Posted October 8, 2007 Author Share Posted October 8, 2007 ??? Date.prototype.addMonths = function(m) { // Adds the number of months to date. // date is typed in <input type='text' id='signdate'>MM/DD/YYYY format var selectdate = document.getElementById('signdate'); selectdate.setMonth(selectdate.getMonth() + m); }; // number of months: is selected in a drop down from 1 to 24 var n = getElementById('howmanymonths').value; expiredate.addMonths(n); // set expire date in mm/dd/yy format. document.getElementById('expiredate').value= expiredate; Link to comment https://forums.phpfreaks.com/topic/72327-solved-add-just-six-months-to-a-given-date/#findComment-364730 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.