title: How to get First and Last Day of Previous Month with Carbon - Laravel
body: <p>I need <strong>First</strong> and <strong>Last Day</strong> of <strong>Previous Month</strong> using Carbon Library, what I have tried is as follows:</p>
  
  <pre><code>$firstDayofPreviousMonth = Carbon::now()-&gt;startOfMonth()-&gt;subMonth()-&gt;toDateString();
  $lastDayofPreviousMonth = Carbon::now()-&gt;endOfMonth()-&gt;subMonth()-&gt;toDateString();
  </code></pre>
  
  <p>Result I'm getting is for<code>$firstDayofPreviousMonth = '2016-04-01'</code>(as current month is 5th(May)) and for <code>$lastDayofPreviousMonth = '2016-05-01'</code>.</p>
  
  <p>I'm getting correct result for <code>$firstDayofPreviousMonth</code>, but it's giving me 30 days previous result, and giving me wrong result for <code>$lastDayofPreviousMonth</code>.</p>
  
  <p>Can anyone help me out with this?</p>