svn: /phpdoc/en/trunk/reference/datetime/dateinterval/ construct.xml
| From: | Daniel Convissor | Date: | Thu, 27 Aug 2009 22:15:31 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/datetime/dateinterval/ construct.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-4781@lists.php.net to get a copy of this message | ||
danielc Thu, 27 Aug 2009 22:15:31 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=287821
Log:
explain the interval format
Changed paths:
U phpdoc/en/trunk/reference/datetime/dateinterval/construct.xml
Modified: phpdoc/en/trunk/reference/datetime/dateinterval/construct.xml
===================================================================
--- phpdoc/en/trunk/reference/datetime/dateinterval/construct.xml 2009-08-27 21:43:12 UTC (rev
287820)
+++ phpdoc/en/trunk/reference/datetime/dateinterval/construct.xml 2009-08-27 22:15:31 UTC (rev
287821)
@@ -28,12 +28,91 @@
<para>
Interval specification.
</para>
+ <para>
+ The <emphasis>date portion</emphasis>, if any,
+ starts with the letter <literal>P</literal>.
+ Each date unit is represented by an integer value
+ followed by the letter indicating the unit type.
+ The date unit types are
+ <literal>Y</literal> for years,
+ <literal>M</literal> for months and
+ <literal>D</literal> for days.
+ For example, the format to create a two day
+ interval is <literal>P2D</literal>.
+ </para>
+ <para>
+ The <emphasis>time portion</emphasis>, if any,
+ starts with the letter <literal>T</literal>.
+ Each time unit is represented by an integer value
+ followed by the letter indicating the unit type.
+ The time unit types are
+ <literal>H</literal> for hours,
+ <literal>M</literal> for minutes and
+ <literal>S</literal> for seconds.
+ For example, the format to create a two second
+ interval is <literal>T2S</literal>.
+ </para>
+ <para>
+ The date and time portions can be combined. To
+ demonstrate, an interval of six years and five minutes
+ is represented by <literal>P6YT5M</literal>.
+ </para>
+ <note>
+ <para>
+ The unit types must be entered from the largest
+ scale unit on the left to the smallest scale unit
+ on the right.
+ So dates come before times, years before months,
+ months before days, days before minutes, etc.
+ So one year and four days must be
+ <literal>P1Y4D</literal>, not <literal>P4D1Y</literal>.
+ </para>
+ </note>
+ <para>
+ The format can also be entered in an ISO format.
+ A sample of one year and four days would be
+ <literal>P0001-00-04T00:00:00</literal>.
+ </para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
+ <refsect1 role="examples">
+ &reftitle.examples;
+ <para>
+ <example>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+$interval = new DateInterval('P2Y4DT6H8M');
+print_r($interval);
+
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen role="php">
+<![CDATA[
+DateInterval Object
+(
+ [y] => 2
+ [m] => 0
+ [d] => 4
+ [h] => 6
+ [i] => 8
+ [s] => 0
+ [invert] => 0
+ [days] => 0
+)
+]]>
+ </screen>
+ </example>
+ </para>
+ </refsect1>
+
</refentry>
<!-- Keep this comment at the end of the file