Here am trying to change date which am showing in div, here i have previous and next buttons & when i will click on Next button then the my current date should be got changed there i need a date of next day, previous date by clicking on previous button/div like bellow snapp
Here if i will cleck right side (>) text then the date should got changed as 9/9/2016,and when i will clicked on (<) text the date should got changed as 7/9/2016 & same thing should happen with month if we will reached to the eand of month means here suppose the date is 30/9/2016 and i will click on Next(< text) then the date should got displayed like 1/10/2016 and if am at 1/9/2016 and am clicking on previous(< text) then date should got displayed like 31/8/2016,can any one help me with this ?I tried something as like bellow but there is issue with date format
$("#prevDate").unbind('click').click(function () {
var actualDate = new Date(document.getElementById("Date").innerHTML);
var newDate = new Date(actualDate.getFullYear(), actualDate.getMonth(), actualDate.getDate()-1);
var converdate=newDate.toString().split(" ");
var dayName=converdate[0];
var month=converdate[1];
var dayNumber=converdate[2];
var year=converdate[3];
var newdte= dayName+","+month+","+dayNumber+","+year;
document.getElementById("Date").innerHTML=newdte;
document.getElementById("result").innerHTML=newdte;
});
$("#nextDate").unbind('click').click(function () {
var actualDate = new Date(document.getElementById("Date").innerHTML);
var newDate = new Date(actualDate.getFullYear(), actualDate.getMonth(), actualDate.getDate()+1);
var converdate=newDate.toString().split(" ");
var dayName=converdate[0];
var month=converdate[1];
var dayNumber=converdate[2];
var year=converdate[3];
var newdte= dayName+","+month+","+dayNumber+","+year;
document.getElementById("Date").innerHTML=newdte;
document.getElementById("result").innerHTML=newdte;
});
here am passing date in dd/mm/yyyy format and it considered it as mm/dd/yyyy format this is the problem am facing