I am increasing and decreasing date in my application by clicking nextDay and previousDay, date is incrementing But once it reached the month end like 31, 30, 29(feb), 28(feb) then it should change the month as well as date also. But its keep on incrementing. Till now i have tried with below code
var today = new Date();
var days = ["Sunday","Monday","Tuesday",
"Wednesday","Thursday","Friday","Saturday"];
var months = ["January","February","March",
"April","May","June","July","August",
"September","October","November","December"];
var nextDate = 0;
function set_todayDate() {
document.getElementById("todaysDate").innerHTML =
""+days[today.getDay()]+",
"+months[today.getMonth()]+"
"+today.getDate()+"
"+today.getFullYear();
}
For next date and previous date, Just I am increasing and decreasing variable
function nextDateMethod(){
nextDate++;
document.getElementById("todaysDate").innerHTML = ""+days[today.getDay()
+dayIncrement]+
", "+months[today.getMonth()]+"
"+(today.getDate()+dayIncrement)+""+today.getFullYear();
}
function prevDate(){
nextDate--;
document.getElementById("todaysDate").
innerHTML = months[today.getMonth()]+",
"+(today.getDate()+nextDate)+" "+today.getFullYear();
}
Please anybody help me