<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.dateinterval" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">

 <title>The DateInterval class</title>
 <titleabbrev>DateInterval</titleabbrev>

 <partintro>

<!-- {{{ DateInterval intro -->
  <section xml:id="dateinterval.intro">
   &reftitle.intro;
   <para>
    Represents a date interval.
   </para>
   <para>
    A date interval stores either a fixed amount of time (in years, months,
    days, hours etc) or a relative time string in the format that
    <classname>DateTimeImmutable</classname>'s and
    <classname>DateTime</classname>'s constructors support.
   </para>
   <para>
    More specifically, the information in an object of the
    <classname>DateInterval</classname> class is an instruction to get from
    one date/time to another date/time. This process is not always reversible.
   </para>
   <para>
    A common way to create a <classname>DateInterval</classname> object
    is by calculating the difference between two date/time objects through
    <methodname>DateTimeInterface::diff</methodname>.
   </para>
   <para>
    Since there is no well defined way to compare date intervals,
    <classname>DateInterval</classname> instances are
    <link linkend="language.operators.comparison.incomparable">incomparable</link>.
   </para>
  </section>
<!-- }}} -->

  <section xml:id="dateinterval.synopsis">
   &reftitle.classsynopsis;

<!-- {{{ Synopsis -->
   <classsynopsis class="class">
    <ooclass>
     <classname>DateInterval</classname>
    </ooclass>

    <classsynopsisinfo role="comment">&Properties;</classsynopsisinfo>
    <fieldsynopsis>
     <modifier>public</modifier>
     <type>int</type>
     <varname linkend="dateinterval.props.y">y</varname>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>public</modifier>
     <type>int</type>
     <varname linkend="dateinterval.props.m">m</varname>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>public</modifier>
     <type>int</type>
     <varname linkend="dateinterval.props.d">d</varname>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>public</modifier>
     <type>int</type>
     <varname linkend="dateinterval.props.h">h</varname>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>public</modifier>
     <type>int</type>
     <varname linkend="dateinterval.props.i">i</varname>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>public</modifier>
     <type>int</type>
     <varname linkend="dateinterval.props.s">s</varname>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>public</modifier>
     <type>float</type>
     <varname linkend="dateinterval.props.f">f</varname>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>public</modifier>
     <type>int</type>
     <varname linkend="dateinterval.props.invert">invert</varname>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>public</modifier>
     <type>mixed</type>
     <varname linkend="dateinterval.props.days">days</varname>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>public</modifier>
     <type>bool</type>
     <varname linkend="dateinterval.props.from-string">from_string</varname>
    </fieldsynopsis>
    <fieldsynopsis>
     <modifier>public</modifier>
     <type>string</type>
     <varname linkend="dateinterval.props.date-string">date_string</varname>
    </fieldsynopsis>
    
    <classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
    <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateinterval')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[@role='DateInterval'])">
     <xi:fallback/>
    </xi:include>
    <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.dateinterval')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[@role='DateInterval'])">
     <xi:fallback/>
    </xi:include>
   </classsynopsis>
<!-- }}} -->

  </section>
  
  <section xml:id="dateinterval.props">
   &reftitle.properties;
   <warning>
    <para>
     The available properties listed below depend on PHP version, and should
     be considered as <emphasis>readonly</emphasis>.
    </para>
   </warning>
   <variablelist>
    <varlistentry xml:id="dateinterval.props.y">
     <term><varname>y</varname></term>
     <listitem>
      <para>
       Number of years.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry xml:id="dateinterval.props.m">
     <term><varname>m</varname></term>
     <listitem>
      <para>
       Number of months.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry xml:id="dateinterval.props.d">
     <term><varname>d</varname></term>
     <listitem>
      <para>
       Number of days.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry xml:id="dateinterval.props.h">
     <term><varname>h</varname></term>
     <listitem>
      <para>
       Number of hours.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry xml:id="dateinterval.props.i">
     <term><varname>i</varname></term>
     <listitem>
      <para>
       Number of minutes.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry xml:id="dateinterval.props.s">
     <term><varname>s</varname></term>
     <listitem>
      <para>
       Number of seconds.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry xml:id="dateinterval.props.f">
     <term><varname>f</varname></term>
     <listitem>
      <para>
       Number of microseconds, as a fraction of a second.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry xml:id="dateinterval.props.invert">
     <term><varname>invert</varname></term>
     <listitem>
      <para>
       Is <literal>1</literal> if the interval
       represents a negative time period and
       <literal>0</literal> otherwise.
       See <methodname>DateInterval::format</methodname>.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry xml:id="dateinterval.props.days">
     <term><varname>days</varname></term>
     <listitem>
      <para>
       If the DateInterval object was created by
       <methodname>DateTimeImmutable::diff</methodname> or
       <methodname>DateTime::diff</methodname>, then this is the
       total number of full days between the start and end dates. Otherwise,
       <varname>days</varname> will be &false;.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry xml:id="dateinterval.props.from-string">
     <term><varname>from_string</varname></term>
     <listitem>
      <para>
       If the DateInterval object was created by
       <methodname>DateInterval::createFromDateString</methodname>, then
       this property's value will be &true;, and the
       <varname>date_string</varname> property will be populated. Otherwise,
       the value will be &false;, and the <varname>y</varname> to
       <varname>f</varname>, <varname>invert</varname>, and
       <varname>days</varname> properties will be populated.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry xml:id="dateinterval.props.date-string">
     <term><varname>date_string</varname></term>
     <listitem>
      <para>
       The string used as argument to
       <methodname>DateInterval::createFromDateString</methodname>.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </section>

  <section role="changelog" xml:id="dateinterval.changelog"><!-- {{{ -->
   &reftitle.changelog;
   <para>
    <informaltable>
     <tgroup cols="2">
      <thead>
       <row>
        <entry>&Version;</entry>
        <entry>&Description;</entry>
       </row>
      </thead>
      <tbody>
       <row>
        <entry>8.2.0</entry>
        <entry>
         The <varname>from_string</varname> and <varname>date_string</varname>
         properties were added for <classname>DateInterval</classname>
         instances that were created using the
         <methodname>DateInterval::createFromDateString</methodname> method.
        </entry>
       </row>
       <row>
        <entry>8.2.0</entry>
        <entry>
         Only the <literal>y</literal> to <literal>f</literal>,
         <literal>invert</literal>, and <literal>days</literal> will be visible.
        </entry>
       </row>
       <row>
        <entry>7.4.0</entry>
        <entry>
         <classname>DateInterval</classname> instances are incomparable now;
         previously, all <classname>DateInterval</classname> instances were considered equal.
        </entry>
       </row>
       <row>
        <entry>7.1.0</entry>
        <entry>The <varname>f</varname> property was added.</entry>
       </row>
      </tbody>
     </tgroup>
    </informaltable>
   </para>
  </section><!-- }}} -->

 </partintro>

 &reference.datetime.entities.dateinterval;

</phpdoc:classref>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
