1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<reference xml:id="class.dateinterval" role="class" 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;
</reference>
<!-- 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
-->
|