title: Subtracting weeks and months from a date - Is my math correct?
body: <p>I have an input field where the user can set an interval of weeks (only integers). Those weeks are subtracted from an original date in a database. I am using PHP to subtract the weeks and/or months with the following methods:</p>
  
  <pre><code>$date_call_in = date('Y-m-d', strtotime("-$months months", strtotime($date_call_in)));
  
  $date_call_in = date('Y-m-d', strtotime("-$weeks weeks", strtotime($date_call_in)));
  </code></pre>
  
  <p>The problem came if the user enters more than 3 weeks (e.g 4 weeks) as the PHP date function wont calculate and decrement a month, but a maximum of 3 weeks. So if the user entered 4 weeks it would decrement only 3 weeks because it could not understand and shift the month.</p>
  
  <p>Therefore I had to make a smaller calculation to translate the remainding weeks from a month if the input was higher than 3 weeks.</p>
  
  <p>This is my result and it seems to work like a charm. I would be grateful tho if anyone could spot something I have overseen since I dont consider myself a great mathematican.</p>
  
  <p>Here is my function, created in Javascript for the simplicity:
  <a href="https://jsfiddle.net/hq5cp6j3/1/" rel="nofollow">JSfiddle</a></p>
  
  <p>And the code in the fiddle is:</p>
  
  <pre><code>var weeks = 7; //feel free to change this for testing
  
  if (weeks &lt; 4){
    alert ("weeks: " + weeks);
  }else{
    var months = Math.floor(weeks/4);
    weeks = weeks % 4;
    alert("months: " + months + ", weeks: " + weeks);
  }
  </code></pre>
  
  <p>Do you agree with the solution or did I miss something? Thanks for taking your time to read this.</p>
  
  <p><strong>EDIT:</strong>
  Here is a link to the whole method: <a href="http://pastebin.com/7b4hvA5P" rel="nofollow">Pastebin</a></p>