Why was the DateTime object copied by reference in this code? Here is my code:
<?php date_default_timezone_set('UTC'); $dt1 = new \DateTime('2015-03-15'); $dt2 = $dt1; $dt2 = $dt2->modify('-1 year'); echo $dt1->format('c') . PHP_EOL; echo $dt2->format('c'); ?>
I expected:
2015-03-15T00:00:00+00:00 2014-03-15T00:00:00+00:00
But I got this:
2014-03-15T00:00:00+00:00 2014-03-15T00:00:00+00:00
source share