<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>The DatePeriod class</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="dateinterval.format.html">DateInterval::format</a></div> <div class="next" style="text-align: right; float: right;"><a href="dateperiod.construct.html">DatePeriod::__construct</a></div> <div class="up"><a href="book.datetime.html">Date/Time</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="class.dateperiod" class="reference"> <h1 class="title">The DatePeriod class</h1> <div class="partintro"><p class="verinfo">(PHP 5 >= 5.3.0, PHP 7)</p> <div class="section" id="dateperiod.intro"> <h2 class="title">Introduction</h2> <p class="para"> Represents a date period. </p> <p class="para"> A date period allows iteration over a set of dates and times, recurring at regular intervals, over a given period. </p> </div> <div class="section" id="dateperiod.synopsis"> <h2 class="title">Class synopsis</h2> <div class="classsynopsis"> <div class="ooclass"></div> <div class="classsynopsisinfo"> <span class="ooclass"> <strong class="classname">DatePeriod</strong> </span> <span class="oointerface">implements <span class="interfacename"><a href="class.traversable.html" class="interfacename">Traversable</a></span> </span> {</div> <div class="classsynopsisinfo classsynopsisinfo_comment">/* Constants */</div> <div class="fieldsynopsis"> <span class="modifier">const</span> <span class="type">integer</span> <var class="fieldsynopsis_varname"><a href="class.dateperiod.html#dateperiod.constants.exclude-start-date"><var class="varname">EXCLUDE_START_DATE</var></a></var> <span class="initializer"> = 1</span> ;</div> <div class="classsynopsisinfo classsynopsisinfo_comment">/* Properties */</div> <div class="fieldsynopsis"> <span class="modifier">public</span> <span class="type">integer</span> <var class="varname"><a href="class.dateperiod.html#dateperiod.props.recurrences">$<var class="varname">recurrences</var></a></var> ;</div> <div class="fieldsynopsis"> <span class="modifier">public</span> <span class="type">boolean</span> <var class="varname"><a href="class.dateperiod.html#dateperiod.props.include_start_date">$<var class="varname">include_start_date</var></a></var> ;</div> <div class="fieldsynopsis"> <span class="modifier">public</span> <span class="type"><a href="class.datetimeinterface.html" class="type DateTimeInterface">DateTimeInterface</a></span> <var class="varname"><a href="class.dateperiod.html#dateperiod.props.start">$<var class="varname">start</var></a></var> ;</div> <div class="fieldsynopsis"> <span class="modifier">public</span> <span class="type"><a href="class.datetimeinterface.html" class="type DateTimeInterface">DateTimeInterface</a></span> <var class="varname"><a href="class.dateperiod.html#dateperiod.props.current">$<var class="varname">current</var></a></var> ;</div> <div class="fieldsynopsis"> <span class="modifier">public</span> <span class="type"><a href="class.datetimeinterface.html" class="type DateTimeInterface">DateTimeInterface</a></span> <var class="varname"><a href="class.dateperiod.html#dateperiod.props.end">$<var class="varname">end</var></a></var> ;</div> <div class="fieldsynopsis"> <span class="modifier">public</span> <span class="type"><a href="class.dateinterval.html" class="type DateInterval">DateInterval</a></span> <var class="varname"><a href="class.dateperiod.html#dateperiod.props.interval">$<var class="varname">interval</var></a></var> ;</div> <div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div> <div class="constructorsynopsis dc-description"> <span class="modifier">public</span> <span class="methodname"><a href="dateperiod.construct.html" class="methodname">__construct</a></span> ( <span class="methodparam"><span class="type"><a href="class.datetimeinterface.html" class="type DateTimeInterface">DateTimeInterface</a></span> <code class="parameter">$start</code></span> , <span class="methodparam"><span class="type"><a href="class.dateinterval.html" class="type DateInterval">DateInterval</a></span> <code class="parameter">$interval</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$recurrences</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code></span> ] )</div> <div class="constructorsynopsis dc-description"> <span class="modifier">public</span> <span class="methodname"><a href="dateperiod.construct.html" class="methodname">__construct</a></span> ( <span class="methodparam"><span class="type"><a href="class.datetimeinterface.html" class="type DateTimeInterface">DateTimeInterface</a></span> <code class="parameter">$start</code></span> , <span class="methodparam"><span class="type"><a href="class.dateinterval.html" class="type DateInterval">DateInterval</a></span> <code class="parameter">$interval</code></span> , <span class="methodparam"><span class="type"><a href="class.datetimeinterface.html" class="type DateTimeInterface">DateTimeInterface</a></span> <code class="parameter">$end</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code></span> ] )</div> <div class="constructorsynopsis dc-description"> <span class="modifier">public</span> <span class="methodname"><a href="dateperiod.construct.html" class="methodname">__construct</a></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$isostr</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code></span> ] )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">DateInterval</span> <span class="methodname"><a href="dateperiod.getdateinterval.html" class="methodname">getDateInterval</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">DateTimeInterface</span> <span class="methodname"><a href="dateperiod.getenddate.html" class="methodname">getEndDate</a></span> ( <span class="methodparam">void</span> )</div> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">DateTimeInterface</span> <span class="methodname"><a href="dateperiod.getstartdate.html" class="methodname">getStartDate</a></span> ( <span class="methodparam">void</span> )</div> }</div> </div> <div class="section" id="dateperiod.constants"> <h2 class="title">Predefined Constants</h2> <dl> <dt id="dateperiod.constants.exclude-start-date"><strong><code>DatePeriod::EXCLUDE_START_DATE</code></strong></dt> <dd> <p class="para">Exclude start date, used in <span class="function"><a href="dateperiod.construct.html" class="function">DatePeriod::__construct()</a></span>.</p> </dd> </dl> </div> <div class="section" id="dateperiod.props"> <h2 class="title">Properties</h2> <dl> <dt id="dateperiod.props.recurrences"><var class="varname"><var class="varname">recurrences</var></var></dt> <dd> <p class="para"> The number of recurrences. </p> </dd> <dt id="dateperiod.props.include_start_date"><var class="varname"><var class="varname">include_start_date</var></var></dt> <dd> <p class="para"> Whether to include the start date in the set of recurring dates or not. </p> </dd> <dt id="dateperiod.props.start"><var class="varname"><var class="varname">start</var></var></dt> <dd> <p class="para"> The start date of the period. </p> </dd> <dt id="dateperiod.props.current"><var class="varname"><var class="varname">current</var></var></dt> <dd> <p class="para"> During iteration this will contain the current date within the period. </p> </dd> <dt id="dateperiod.props.end"><var class="varname"><var class="varname">end</var></var></dt> <dd> <p class="para"> The end date of the period. </p> </dd> <dt id="dateperiod.props.interval"><var class="varname"><var class="varname">interval</var></var></dt> <dd> <p class="para"> An ISO 8601 repeating interval specification. </p> </dd> </dl> </div> <div class="section" id="dateperiod.changelog"> <h2 class="title">Changelog</h2> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>5.3.27, 5.4.17</td> <td> The public properties <var class="varname"><var class="varname">recurrences</var></var>, <var class="varname"><var class="varname">include_start_date</var></var>, <var class="varname"><var class="varname">start</var></var>, <var class="varname"><var class="varname">current</var></var>, <var class="varname"><var class="varname">end</var></var> and <var class="varname"><var class="varname">interval</var></var> have been exposed. </td> </tr> </tbody> </table> </p> </div> </div> <h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="dateperiod.construct.html">DatePeriod::__construct</a> — Creates a new DatePeriod object</li><li><a href="dateperiod.getdateinterval.html">DatePeriod::getDateInterval</a> — Gets the interval</li><li><a href="dateperiod.getenddate.html">DatePeriod::getEndDate</a> — Gets the end date</li><li><a href="dateperiod.getstartdate.html">DatePeriod::getStartDate</a> — Gets the start date</li></ul> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="dateinterval.format.html">DateInterval::format</a></div> <div class="next" style="text-align: right; float: right;"><a href="dateperiod.construct.html">DatePeriod::__construct</a></div> <div class="up"><a href="book.datetime.html">Date/Time</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>