title: How to display previous day and next day dates in html using Javascript
body: <p>I am working on some simple Javascript to display the current date with previous and next date links.</p>
  
  <p>my code snippet as follows</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var currentTime = new Date();
  
  var month = currentTime.getMonth()+1;
  var day = currentTime.getDate();
  var year = currentTime.getFullYear();
  var date = month + " " + day + " " + year;
  
  function ShowSchedule() 
  {
  document.getElementById("today").innerHTML = date;
  }
  
  function ShowDay(isNextDay)
  {
  if(isNextDay)
  {
  var nextDay = new Date(year, month, day+1);
  date = nextDay.getMonth() + " " + nextDay.getDate() + " " + nextDay.getFullYear();
  ShowSchedule();
  }
  else{
  var prevDay = new Date(year, month, day -1);
  date= prevDay.getMonth() + " " + prevDay.getDate() + " " + prevDay.getFullYear();
  ShowSchedule();
  }
  }
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;table border="1"&gt;
      &lt;tr&gt;
          &lt;th&gt;
              &lt;a id = "prev" href="#" onClick="ShowDay(false)"&gt;Prev&lt;/a&gt;
          &lt;/th&gt;
          &lt;th id="today"&gt;
          &lt;/th&gt;
          &lt;th&gt;
              &lt;a id = "next" href="#" onClick="ShowDay(true)"&gt;Next&lt;/a&gt;
          &lt;/th&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;script&gt;ShowSchedule();&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The above code working for current, previous and next date also, but the problam is if i click on next day link it will get increase for only one day, same thing for previous link also. My requirement is i can able to whatever date i want by clicking previous and next link navigations.</p>
  
  <p>Any help will be appreciated.</p>