note 112675 added to dateinterval.construct
| From: | owenatbeliefs.com | Date: | Thu, 11 Jul 2013 15:20:37 +0000 |
| Subject: | note 112675 added to dateinterval.construct | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195575@lists.php.net to get a copy of this message | ||
M is used to indicate both months and minutes.
As noted on the referenced wikipedia page for ISO 6801 http://en.wikipedia.org/wiki/Iso8601#Durations
To resolve ambiguity, "P1M" is a one-month duration and "PT1M" is a one-minute
duration (note the time designator, T, that precedes the time value).
Using: PHP 5.3.2-1ubuntu4.19
// For 3 Months
$dateTime = new DateTime;echo $dateTime->format( DateTime::ISO8601 ), PHP_EOL;
$dateTime->add(new DateInterval("P3M"));
echo $dateTime->format( DateTime::ISO8601 ), PHP_EOL;
Results in:
2013-07-11T11:12:26-0400
2013-10-11T11:12:26-0400
// For 3 Minutes
$dateTime = new DateTime;echo $dateTime->format( DateTime::ISO8601 ), PHP_EOL;
$dateTime->add(new DateInterval("PT3M"));
echo $dateTime->format( DateTime::ISO8601 ), PHP_EOL;
Results in:
2013-07-11T11:12:42-0400
2013-07-11T11:15:42-0400
Insert a T after the P in the interval to add 3 minutes instead of 3 months.
----
Server IP: 69.147.83.199
Probable Submitter: 71.183.18.83
----
Manual Page -- http://php.net/manual/en/dateinterval.construct.php
Edit -- https://master.php.net/note/edit/112675
Del: integrated -- https://master.php.net/note/delete/112675/integrated
Del: useless -- https://master.php.net/note/delete/112675/useless
Del: bad code -- https://master.php.net/note/delete/112675/bad+code
Del: spam -- https://master.php.net/note/delete/112675/spam
Del: non-english -- https://master.php.net/note/delete/112675/non-english
Del: in docs -- https://master.php.net/note/delete/112675/in+docs
Del: other reasons-- https://master.php.net/note/delete/112675
Reject -- https://master.php.net/note/reject/112675
Search -- https://master.php.net/manage/user-notes.php