Answer the question
In order to leave comments, you need to log in
Is there a method like DateTime->add() that doesn't change the DateTime itself?
Actually the essence is in the catch - is there a method that adds a DateInterval, BUT not changing the object from which we called this method, but returning the changed value? Or are we still doomed to use clone, write it to a variable, and only then call add?
Answer the question
In order to leave comments, you need to log in
Yes, if you use the DateTimeImmutable class instead of DateTime. php.net/manual/en/class.datetimeimmutable.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question