title: How to get last month date in java script or jquery
body: <p>I am trying to get specific date in java script.</p>
  
  <p>What I am trying to do is.
  I have variable called <code>frequency</code> Which can be <code>Daily</code> , <code>Weekly</code> and <code>Monthly</code></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>if(frequency=="daily")
  {
      date='current_date -2 days';
  }
      else if ( frequency== 'weekly')
  {
      date='current_date -8 days';
  }
      else if ( frequency == 'monthly')
  {
      date='current_date -32 days';
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is the way I get current date with required format.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var today = new Date();
  var dd = today.getDate();
  var mm = today.getMonth()+1; //January is 0!
  var yyyy = today.getFullYear();
  var hh = today.getHours();
  var min = today.getMinutes();
  var ss = today.getSeconds();
  
  if(dd&lt;10) {
      dd='0'+dd
  } 
  
  if(mm&lt;10) {
      mm='0'+mm
  } 
  
  //  today = mm+'/'+dd+'/'+yyyy;
  
  today = yyyy + "-" + mm + "-" + dd + " " + hh + ":" + mm + ":" + ss ;
  alert("Today's date :"+today);</code></pre>
  </div>
  </div>
  </p>
  
  <p>But, I am facing problem in subtracting the days </p>
  
  <p>can anyone give an idea how can I achieve this.  </p>