title: Difference between two dates with 360 days/year, 30 days/month format in php
body: <p>I want to ask a question regarding the answer given in this post (<a href="https://stackoverflow.com/questions/35832487/how-to-get-the-difference-between-two-dates-with-360-days-year-30-days-month-fo">How to get the difference between two dates with 360 days/year, 30 days/month format?</a>) which i can't comment because i don't have the necessary reputation.
  The provided function</p>
  <pre><code>function diff360($date1, $date2) {
      $date1 = new DateTime($date1);
      $date2 = new DateTime($date2);
      $diff = $date1-&gt;diff($date2);
      $days = ($date2-&gt;format('d') + 30 - $date1-&gt;format('d')) % 30;
      return array(
          &quot;y&quot; =&gt; $diff-&gt;y,
          &quot;m&quot; =&gt; $diff-&gt;m,
          &quot;d&quot; =&gt; $days,
          &quot;totaldays&quot; =&gt; $diff-&gt;y * 360 + $diff-&gt;m * 30 + $days
      );
  }
  </code></pre>
  <p>generally works well except for certain cases e.g. <code>diff360(&quot;2020-09-01&quot;, &quot;2021-07-01&quot;);</code> where it outputs &quot;0 years,9 months,0 days&quot;, instead of the desired &quot;0 years, 10 months, 0 days&quot;.
  Can you please explain why?</p>