title: put the remaining first days in last month mysql
body: <pre><code>$contract_start_date = '2016-09-01';
  $contract_end_date = '2017-10-31';
  $no_of_months = 1 + (date("Y", $contract_end_date) - date("Y", $contract_start_date)) * 12; 
  $no_of_months += date("m", $contract_end_date) - date("m", $contract_start_date); 
  $no_of_months = intval($no_of_months);
  </code></pre>
  
  <p>Here I have got a contract which is for a year. Now, I have two pay methods: Advance and Deferred. </p>
  
  <blockquote>
    <p><strong>Advance method</strong>, I get the bill for every first date of every month(say y-m-01), </p>
  </blockquote>
  
  <p>and in </p>
  
  <blockquote>
    <p><strong>Deferred method</strong>, I get the bill for every last date of every month(y-m-last_date),</p>
  </blockquote>
  
  <p>if the contract starts exactly at first date of any month and any year.</p>
  
  <p>If example my new contract starts at '2016-09-15' and ends at '2017-10-14',
  then the bill generated should be like this: 
  Advance method: 
  1st bill:</p>
  
  <pre><code>$contract_start_date ='2016-09-15'value(('for the period between '2016-09-15' to '2016-09-31''));
  </code></pre>
  
  <p>then the other bills will be of date <strong>'y-m-01'</strong> for very month till <code>$contract_end_date</code>. Now the remaining 14 days of first_month should be generated after the <code>$contract_end_date</code>, say I have to get the bill for 14 days on <code>'2017-11-01'</code>. So how can I achieve this? Please give some tips.</p>