note 115335 added to datetimeimmutable.modify

From: Date: Mon, 07 Jul 2014 11:24:38 +0000
Subject: note 115335 added to datetimeimmutable.modify
Groups: php.notes 
Request: Send a blank email to php-notes+get-199877@lists.php.net to get a copy of this message
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. ---- Server IP: 72.52.91.14 Probable Submitter: 81.145.183.178 ---- Manual Page -- http://php.net/manual/en/datetimeimmutable.modify.php Edit -- https://master.php.net/note/edit/115335 Del: integrated -- https://master.php.net/note/delete/115335/integrated Del: useless -- https://master.php.net/note/delete/115335/useless Del: bad code -- https://master.php.net/note/delete/115335/bad+code Del: spam -- https://master.php.net/note/delete/115335/spam Del: non-english -- https://master.php.net/note/delete/115335/non-english Del: in docs -- https://master.php.net/note/delete/115335/in+docs Del: other reasons-- https://master.php.net/note/delete/115335 Reject -- https://master.php.net/note/reject/115335 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#199877) next »