Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 755

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!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 DateTimeInterface interface</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="datetimeimmutable.sub.html">DateTimeImmutable::sub</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="datetime.diff.html">DateTime::diff</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.datetimeinterface" class="reference">

 <h1 class="title">The DateTimeInterface interface</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7)</p>


  <div class="section" id="datetimeinterface.intro">
   <h2 class="title">Introduction</h2>
   <p class="para">
    DateTimeInterface is meant so that both DateTime and DateTimeImmutable can
    be type hinted for. It is not possible to implement this interface with
    userland classes.
   </p>
  </div>


  <div class="section" id="datetimeinterface.synopsis">
   <h2 class="title">Class synopsis</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <strong class="classname">DateTimeInterface</strong>
     </span>
     {</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Constants */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">string</span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.html#datetime.constants.atom"><var class="varname">ATOM</var></a></var>
     <span class="initializer"> = &quot;Y-m-d\TH:i:sP&quot;</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">string</span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.html#datetime.constants.cookie"><var class="varname">COOKIE</var></a></var>
     <span class="initializer"> = &quot;l, d-M-Y H:i:s T&quot;</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">string</span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.html#datetime.constants.iso8601"><var class="varname">ISO8601</var></a></var>
     <span class="initializer"> = &quot;Y-m-d\TH:i:sO&quot;</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">string</span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.html#datetime.constants.rfc822"><var class="varname">RFC822</var></a></var>
     <span class="initializer"> = &quot;D, d M y H:i:s O&quot;</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">string</span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.html#datetime.constants.rfc850"><var class="varname">RFC850</var></a></var>
     <span class="initializer"> = &quot;l, d-M-y H:i:s T&quot;</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">string</span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.html#datetime.constants.rfc1036"><var class="varname">RFC1036</var></a></var>
     <span class="initializer"> = &quot;D, d M y H:i:s O&quot;</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">string</span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.html#datetime.constants.rfc1123"><var class="varname">RFC1123</var></a></var>
     <span class="initializer"> = &quot;D, d M Y H:i:s O&quot;</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">string</span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.html#datetime.constants.rfc2822"><var class="varname">RFC2822</var></a></var>
     <span class="initializer"> = &quot;D, d M Y H:i:s O&quot;</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">string</span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.html#datetime.constants.rfc3339"><var class="varname">RFC3339</var></a></var>
     <span class="initializer"> = &quot;Y-m-d\TH:i:sP&quot;</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">string</span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.html#datetime.constants.rfc3339_extended"><var class="varname">RFC3339_EXTENDED</var></a></var>
     <span class="initializer"> = &quot;Y-m-d\TH:i:s.vP&quot;</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">string</span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.html#datetime.constants.rss"><var class="varname">RSS</var></a></var>
     <span class="initializer"> = &quot;D, d M Y H:i:s O&quot;</span>
    ;</div>

    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">string</span>
      <var class="fieldsynopsis_varname"><a href="class.datetimeinterface.html#datetime.constants.w3c"><var class="varname">W3C</var></a></var>
     <span class="initializer"> = &quot;Y-m-d\TH:i:sP&quot;</span>
    ;</div>

    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div>
    <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">DateInterval</span> <span class="methodname"><a href="datetime.diff.html" class="methodname">diff</a></span>
    ( <span class="methodparam"><span class="type"><a href="class.datetimeinterface.html" class="type DateTimeInterface">DateTimeInterface</a></span> <code class="parameter">$datetime2</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$absolute</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
  ] )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">string</span> <span class="methodname"><a href="datetime.format.html" class="methodname">format</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$format</code></span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span> <span class="methodname"><a href="datetime.getoffset.html" class="methodname">getOffset</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">int</span> <span class="methodname"><a href="datetime.gettimestamp.html" class="methodname">getTimestamp</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">DateTimeZone</span> <span class="methodname"><a href="datetime.gettimezone.html" class="methodname">getTimezone</a></span>
    ( <span class="methodparam">void</span>
   )</div>
<div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="datetime.wakeup.html" class="methodname">__wakeup</a></span>
    ( <span class="methodparam">void</span>
   )</div>

   }</div>


  </div>


  <div class="section" id="datetime.constants.types">
   <h2 class="title">Predefined Constants</h2>
   <dl>

    
     <dt id="datetime.constants.atom"><strong><code>DateTimeInterface::ATOM</code></strong></dt>

     <dt>
<strong><code>DATE_ATOM</code></strong></dt>

     <dd>

      <span class="simpara">
       Atom (example: 2005-08-15T15:52:01+00:00)
      </span>
     </dd>

    

    
     <dt id="datetime.constants.cookie"><strong><code>DateTimeInterface::COOKIE</code></strong></dt>

     <dt>
<strong><code>DATE_COOKIE</code></strong></dt>

     <dd>

      <span class="simpara">
       HTTP Cookies (example: Monday, 15-Aug-2005 15:52:01 UTC)
      </span>
     </dd>

    

    
     <dt id="datetime.constants.iso8601"><strong><code>DateTimeInterface::ISO8601</code></strong></dt>

     <dt>
<strong><code>DATE_ISO8601</code></strong></dt>

     <dd>

      <span class="simpara">
       ISO-8601 (example: 2005-08-15T15:52:01+0000)
      </span>
      <blockquote class="note"><p><strong class="note">Note</strong>: 
       <span class="simpara">
        This format is not compatible with ISO-8601, but is left this way for
        backward compatibility reasons. Use <strong><code>DateTime::ATOM</code></strong>
        or <strong><code>DATE_ATOM</code></strong> for compatibility with ISO-8601
        instead.
       </span>
      </p></blockquote>
     </dd>

    

    
     <dt id="datetime.constants.rfc822"><strong><code>DateTimeInterface::RFC822</code></strong></dt>

     <dt>
<strong><code>DATE_RFC822</code></strong></dt>

     <dd>

      <span class="simpara">
       RFC 822 (example: Mon, 15 Aug 05 15:52:01 +0000)
      </span>
     </dd>

    

    
     <dt id="datetime.constants.rfc850"><strong><code>DateTimeInterface::RFC850</code></strong></dt>

     <dt>
<strong><code>DATE_RFC850</code></strong></dt>

     <dd>

      <span class="simpara">
       RFC 850 (example: Monday, 15-Aug-05 15:52:01 UTC)
      </span>
     </dd>

    

    
     <dt id="datetime.constants.rfc1036"><strong><code>DateTimeInterface::RFC1036</code></strong></dt>

     <dt>
<strong><code>DATE_RFC1036</code></strong></dt>

     <dd>

      <span class="simpara">
       RFC 1036 (example: Mon, 15 Aug 05 15:52:01 +0000)
      </span>
     </dd>

    

    
     <dt id="datetime.constants.rfc1123"><strong><code>DateTimeInterface::RFC1123</code></strong></dt>

     <dt>
<strong><code>DATE_RFC1123</code></strong></dt>

     <dd>

      <span class="simpara">
       RFC 1123 (example: Mon, 15 Aug 2005 15:52:01 +0000)
      </span>
     </dd>

    

    
     <dt id="datetime.constants.rfc2822"><strong><code>DateTimeInterface::RFC2822</code></strong></dt>

     <dt>
<strong><code>DATE_RFC2822</code></strong></dt>

     <dd>

      <span class="simpara">
       RFC 2822 (example: Mon, 15 Aug 2005 15:52:01 +0000)
      </span>
     </dd>

    

    
     <dt id="datetime.constants.rfc3339"><strong><code>DateTimeInterface::RFC3339</code></strong></dt>

     <dt>
<strong><code>DATE_RFC3339</code></strong></dt>

     <dd>

      <span class="simpara">
       Same as <strong><code>DATE_ATOM</code></strong> (since PHP 5.1.3)
      </span>
     </dd>

    

    
     <dt id="datetime.constants.rfc3339_extended"><strong><code>DateTimeInterface::RFC3339_EXTENDED</code></strong></dt>

     <dt>
<strong><code>DATE_RFC3339_EXTENDED</code></strong></dt>

     <dd>

      <span class="simpara">
       RFC 3339 EXTENDED format (since PHP 7.0.0) (example: 2005-08-15T15:52:01.000+00:00)
      </span>
     </dd>

    

    
     <dt id="datetime.constants.rss"><strong><code>DateTimeInterface::RSS</code></strong></dt>

     <dt>
<strong><code>DATE_RSS</code></strong></dt>

     <dd>

      <span class="simpara">
       RSS (example: Mon, 15 Aug 2005 15:52:01 +0000)
      </span>
     </dd>

    

    
     <dt id="datetime.constants.w3c"><strong><code>DateTimeInterface::W3C</code></strong></dt>

     <dt>
<strong><code>DATE_W3C</code></strong></dt>

     <dd>

      <span class="simpara">
       World Wide Web Consortium (example: 2005-08-15T15:52:01+00:00)
      </span>
     </dd>

    

   </dl>

  </div>


 <div class="section" id="datetimeinterface.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>7.2.0</td>
       <td>
        The class constants of <a href="class.datetime.html" class="classname">DateTime</a> are now defined
        on <strong class="classname">DateTimeInterface</strong>.
       </td>
      </tr>

      <tr>
       <td>5.5.8</td>
       <td>
        Trying to implement <strong class="classname">DateTimeInterface</strong> raises a
        fatal error now. Formerly implementing the interface didn&#039;t raise an
        error, but the behavior was erroneous.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 </div>

 











































<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="datetime.diff.html">DateTime::diff</a> — Returns the difference between two DateTime objects</li><li><a href="datetime.format.html">DateTime::format</a> — Returns date formatted according to given format</li><li><a href="datetime.getoffset.html">DateTime::getOffset</a> — Returns the timezone offset</li><li><a href="datetime.gettimestamp.html">DateTime::getTimestamp</a> — Gets the Unix timestamp</li><li><a href="datetime.gettimezone.html">DateTime::getTimezone</a> — Return time zone relative to given DateTime</li><li><a href="datetime.wakeup.html">DateTime::__wakeup</a> — The __wakeup handler</li></ul>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="datetimeimmutable.sub.html">DateTimeImmutable::sub</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="datetime.diff.html">DateTime::diff</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>