I want to add +1
if the date is sunday
. Below code works for the rest dates. But when I pass 30 sept 2012
I gives me 1 Sept 2012
instead of 1 Oct 2012
in dateMsg
. What is wrong with the code?. Please guide. I guess I'l face same problem in all last date of the month.How to add 1 to whole date rather than just the day?
var monthName=convertMnthNoToName(freeLookEndDt.getMonth()+1);
if (freeLookEndDt.getDay()==0) {
var date=new Date(freeLookEndDt.getFullYear(),freeLookEndDt.getMonth(),
freeLookEndDt.getDate()+1);
var newmonthName=convertMnthNoToName(date.getMonth()+1);
var dateMsg = date.getDate() + '-' + monthName + '-' + freeLookEndDt.getFullYear();
document.forms[0].flEndDt.value=dateMsg;
}
and convertMnthNoToName()
function convertMnthNoToName(val)
{
if(val==01 || val==1)
{
val1="Jan";
}
if(val==02 || val==2)
{
val1="Feb";
}
if(val==03 || val==3)
{
val1="Mar";
}
if(val==04 || val==4)
{
val1="Apr";
}
if(val==05 || val==5)
{
val1="May";
}
if(val==06 || val==6)
{
val1="Jun";
}
if(val==07 || val==7)
{
val1="Jul";
}
if(val==08 || val==8)
{
val1="Aug";
}
if(val==09 || val==9)
{
val1="Sep";
}
if(val==10)
{
val1="Oct";
}
if(val==11)
{
val1="Nov";
}
if(val==12)
{
val1="Dec";
}
return val1;
}
where freeLookEndDt = Sun Sep 30 00:00:00 UTC+0530 2012