note 117963 added to datetime.add
| From: | pedrosalpr at gmail dot com | Date: | Wed, 09 Sep 2015 13:17:04 +0000 |
| Subject: | note 117963 added to datetime.add | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203752@lists.php.net to get a copy of this message | ||
When a datetime object has date '2012-01-30', we have the following object:
object(DateTime)#1233 (3) {
["date"]=>
string(19) "2012-01-30 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(9) "ETC/GMT+3"
}
But, when a month is added:
$date->add(new DateInterval('P1M'));
It will result the following object:
object(DateTime)#1233 (3) {
["date"]=>
string(19) "2012-03-01 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(9) "ETC/GMT+3"
}
It should add a month, so the date to be displayed should be
'2012-02-28', therefore february of 2012, instead of march of 2012.
----
Server IP: 72.52.91.14
Probable Submitter: 177.19.136.2
----
Manual Page -- http://php.net/manual/en/datetime.add.php
Edit -- https://master.php.net/note/edit/117963
Del: integrated -- https://master.php.net/note/delete/117963/integrated
Del: useless -- https://master.php.net/note/delete/117963/useless
Del: bad code -- https://master.php.net/note/delete/117963/bad+code
Del: spam -- https://master.php.net/note/delete/117963/spam
Del: non-english -- https://master.php.net/note/delete/117963/non-english
Del: in docs -- https://master.php.net/note/delete/117963/in+docs
Del: other reasons-- https://master.php.net/note/delete/117963
Reject -- https://master.php.net/note/reject/117963
Search -- https://master.php.net/manage/user-notes.php