title: How do I deep copy a DateTime object?
body: <pre><code>$date1 = $date2 = new DateTime();
  $date2-&gt;add(new DateInterval('P3Y'));
  </code></pre>
  
  <p>Now <code>$date1</code> and <code>$date2</code> contain the same date -- three years from now. I'd like to create two separate datetimes, one which is parsed from a string and one with three years added to it. Currently I've hacked it up like this:</p>
  
  <pre><code>$date2 =  new DateTime($date1-&gt;format(DateTime::ISO8601));
  </code></pre>
  
  <p>but that seems like a horrendous hack. Is there a "correct" way to deep copy a DateTime object?</p>