note 124401 added to datetimeimmutable.construct

From: Date: Mon, 18 Nov 2019 04:53:51 +0000
Subject: note 124401 added to datetimeimmutable.construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-213131@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 a 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/124401 Del: integrated -- https://master.php.net/note/delete/124401/integrated Del: useless -- https://master.php.net/note/delete/124401/useless Del: bad code -- https://master.php.net/note/delete/124401/bad+code Del: spam -- https://master.php.net/note/delete/124401/spam Del: non-english -- https://master.php.net/note/delete/124401/non-english Del: in docs -- https://master.php.net/note/delete/124401/in+docs Del: other reasons-- https://master.php.net/note/delete/124401 Reject -- https://master.php.net/note/reject/124401 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#213131) next »