note 107115 deleted from datetime.sub by danbrown

From: Date: Mon, 09 Jan 2012 18:19:35 +0000
Subject: note 107115 deleted from datetime.sub by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185480@lists.php.net to get a copy of this message
Note Submitter: php at surgeinc dot com ---- Follow up on php at keith tyler dot com: ANY method executed after ->sub() will continue to affect the original date object. Also, due to how object references work, modifying the resulting object of ->sub() will affect the original object. <?php $date = new DateTime(); $d = $date->sub(new DateInterval('P1Y')); $d->getTimestamp(); $d === $date; ?> The use of CLONE on the return of ->sub() avoids this.

« previous php.notes (#185480) next »