note 115335 deleted from datetimeimmutable.modify by salathe

From: Date: Mon, 07 Jul 2014 12:22:48 +0000
Subject: note 115335 deleted from datetimeimmutable.modify by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-199879@lists.php.net to get a copy of this message
Note Submitter: admin at n3tw0rk dot co dot uk ---- Just to clarify, this is just misleading on naming. When you "modify" an immutable object what you actually do is create a new instance of the object with the modification applied to the new object on creation. <?php $date = new DateTimeImmutable( '2014-07-07' ); $newDate = $date->modify( '+1 day' ); echo $date->format( 'Y-m-d' ); // 2014-07-07 echo $newDate->format( 'Y-m-d' ); // 2014-07-08 ?> Hope this clears up some uncertainty regarding this function.

« previous php.notes (#199879) next »