Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get month value from a date

Status
Not open for further replies.

kapshk

Programmer
Sep 14, 2006
2
US
Hello,

I am incrementing current date by 14 days. I want to know the month of this new date so I can assign it to a month drop down in a form. Please Advice. Below is the code:


function choose()
{


var currDate = new Date(now.getYear(), now.getMonth(), now.getDate());
newDate = currDate + 14;


document.forms["formContact"].elements["MoveMonth"].selectedIndex = cmonth;
//I want to know how to get cmonth value

}
 
Hi, thanks for the reply. I had tried using getMonth(), for some reason it is not working.

cMonth = newDate.getMonth();
alert(cMonth);

cMonth does not diplay anything when I try to display it. However, when try to get Month out of currDate using currDate.getMonth() it does set the form drop down to that month. Do you think its the way I adding 14 days?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top