title: php calculate the number of months for invoice delay between two dates
body: <p>ok, I am trying to figure out how to create function to get the number of months delayed for invoice between two dates. I tried many hours, without success, i'm confused where to start...</p>
  <p>Here is the formula:</p>
  <p>FROM: <strong>1/1/2020</strong> TO: <strong>10-02-2021</strong></p>
  <pre><code>Months 1, 2, 3, 4, 5 (if not paid during this months, we count the number of month starting from the next month.)
  count the number of months from the next month, from 6-2020 to 02-2021
  result 9;
  </code></pre>
  <p>Again, we do the same:</p>
  <pre><code>Months: 4, 5, 6, 7, 8
  count the number of months from the next month, from 9-2020 to 02-2021
  result 6;
  
  7, 8, 9, 10, 11
  count the number of months from the next month, from 12-2020 to 02-2021
  result 3;
  
  10, 11, 12, 01, 02
  count the number of months from the next month, from 3-2021 to 02-2021 (not possible since date end in 10-02-2021
  result 0;
  </code></pre>
  <p>so, at the end we count the number of months:</p>
  <p>9 + 6 + 3 + 0 = 18</p>
  <p>function should print &quot;18&quot;.</p>
  <p>thanks in advance!</p>