Hello!
Here's the code I am using to add 6 months to today's current date.
It uses jQuery also. When the "6months" checkbox is checked, I want to have 6 months added to the current date and then insert it into the "Date" textbox.
[CODE]
$("#6months").click(function(){
if ($("#6months").is(":checked"))
{
var d = new Date();
d.setMonth(d.getMonth()+7);
$("#Date").val(d.getFullYear()+"-"+(d.getMonth())+"-"+d.getDate());
}});
[/CODE
Because today's date is: 2012-06-22, the date that appears in the Date textbox is this:
2013-0-22
Hmmm... and, of course, I want it to be:
2012-12-22
Any idea what the '0' is all about or how to correct it?
Thanks!


Reply With Quote

