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