title: How to get start and or end of year of a Carbon instance without modifying it in the process?
body: <p>Examine this self-explanatory code in PHP:</p>
  
  <p><strong>Reality:</strong></p>
  
  <pre><code>$dateTime = Carbon::createFromDateTime(2017, 2, 23);
  
  echo $dateTime; // 2017-02-23 00:00:00
  
  echo $dateTime-&gt;startOfYear(); // 2017-12-31 23:59:59
  
  echo $dateTime; // 2017-12-31 23:59:59
  </code></pre>
  
  <p>Notice that on the 4th line, the value of <code>$dateTime</code> is <code>2017-12-31 23:59:59</code>. That is because on the 3rd line.</p>
  
  <p>But why? I know that Carbon's startOfYear() is a modifier, but how can we therefore get a date's start of the year without modifying itself</p>
  
  <p><strong>Expected:</strong></p>
  
  <pre><code>$dateTime = Carbon::createFromDateTime(2017, 2, 23);
  
  echo $dateTime; // 2017-02-23 00:00:00
  
  echo $dateTime-&gt;startOfYear(); // 2017-12-31 23:59:59
  
  echo $dateTime; // 2017-02-23 00:00:00
  </code></pre>
  
  <p>Above, notice the 4th line. In reality, the 4th line outputs <code>2017-12-31 23:59:59</code>.</p>