note 124402 added to datetimeimmutable.construct

From: Date: Mon, 18 Nov 2019 04:54:07 +0000
Subject: note 124402 added to datetimeimmutable.construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-213132@lists.php.net to get a copy of this message
As the type of the first parameter is string, we can assign a relative date for it. Example: <?php $immutable = new DateTimeImmutable('-1 year', new DateTimeZone('Asia/ShangHai')); echo $immutable->format('Y-m-d H:i:s'); ?> It looks like the parameter of function strtotime and is very helpful for us to get an immutable relative DateTime object. ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.168 (proxied: 3.0.207.6) ---- Manual Page -- http://php.net/manual/en/datetimeimmutable.construct.php Edit -- https://master.php.net/note/edit/124402 Del: integrated -- https://master.php.net/note/delete/124402/integrated Del: useless -- https://master.php.net/note/delete/124402/useless Del: bad code -- https://master.php.net/note/delete/124402/bad+code Del: spam -- https://master.php.net/note/delete/124402/spam Del: non-english -- https://master.php.net/note/delete/124402/non-english Del: in docs -- https://master.php.net/note/delete/124402/in+docs Del: other reasons-- https://master.php.net/note/delete/124402 Reject -- https://master.php.net/note/reject/124402 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#213132) next »