|
-
Jun 22nd, 2012, 05:59 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Javascript: Adding Month To Current Date
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|