<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/book.datetime.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'datetime.formats.php',
    1 => 'Supported Date and Time Formats',
    2 => 'Supported Date and Time Formats',
  ),
  'up' => 
  array (
    0 => 'book.datetime.php',
    1 => '日期/时间',
  ),
  'prev' => 
  array (
    0 => 'datetime.error.tree.php',
    1 => '日期/时间 Error 和 Exception',
  ),
  'next' => 
  array (
    0 => 'timezones.php',
    1 => '所支持的时区列表',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/datetime/formats.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="datetime.formats" class="chapter">
 <h1 class="title">Supported Date and Time Formats</h1>


 <p class="para">
  This section describes all the different formats in a BNF-like format, that the
  <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span>, <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span>,
  <span class="function"><a href="function.date-create-immutable.php" class="function">date_create_immutable()</a></span>,
  <span class="function"><a href="function.date-create.php" class="function">date_create()</a></span>, <span class="function"><a href="function.date-parse.php" class="function">date_parse()</a></span>, and
  <span class="function"><a href="function.strtotime.php" class="function">strtotime()</a></span> parser understands. The formats are grouped
  by section. In most cases formats from different sections, separated by
  whitespace, comma or dot, can be used in the same date/time string. For each
  of the supported formats, one or more examples are given, as well
  as a description for the format. Characters in single quotes in
  the formats are case-insensitive (<code class="literal">&#039;t&#039;</code> could
  be <code class="literal">t</code> or <code class="literal">T</code>), characters in
  double quotes are case-sensitive (<code class="literal">&quot;T&quot;</code> is only
  <code class="literal">T</code>).
 </p>
 <p class="para">
  To format <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span> and
  <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span> objects, please refer to the documentation
  of the <span class="function"><a href="datetime.format.php" class="function">DateTimeInterface::format()</a></span> method.
 </p>

 <p class="para">
  A general set of rules should be taken into account.
 </p>
 <ol type="1">
  <li class="listitem">
   <span class="simpara">
    The parser, allows for each unit (year, month, day, hour, minute, second)
    the full range of values. For a year that&#039;s just 4 digits, for a month
    that&#039;s 0-12, day is 0-31, hour is 0-24, and minute is 0-59.
   </span>
  </li>
  <li class="listitem">
   <span class="simpara">
    60 is allowed for seconds, as sometimes date strings with that
    leapsecond do show up. But PHP implements Unix time where &quot;60&quot; is not
    a valid second number and hence it overflows.
   </span>
  </li>
  <li class="listitem">
   <span class="simpara">
    <span class="function"><a href="function.strtotime.php" class="function">strtotime()</a></span> returns <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if any number is outside of
    the ranges, and <span class="function"><a href="datetimeimmutable.construct.php" class="function">DateTimeImmutable::__construct()</a></span> throws
    an exception.
   </span>
  </li>
  <li class="listitem">
   <span class="simpara">
    If a string contains a date, all time elements are reset to 0.
   </span>
  </li>
  <li class="listitem">
   <span class="simpara">
    All less-significant time elements are reset to 0 if any part of a time is
    present in the given string.
   </span>
  </li>
  <li class="listitem">
   <span class="simpara">
    The parser is dumb, and doesn&#039;t do any checks to make it faster (and
    more generic).
   </span>
  </li>
  <li class="listitem">
   <span class="simpara">
    Besides rules for individual time elements, the parser also understand
    more specific <a href="datetime.formats.php#datetime.formats.compound" class="link">compound
    formats</a>, such as parsing Unix timestamps
    (<code class="literal">@1690388256</code>) and ISO Weekdates
    (<code class="literal">2008-W28-3</code>).
   </span>
  </li>
  <li class="listitem">
   <p class="para">
    There is an additional check if an invalid date is provided:
    <div class="informalexample">
     <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$res </span><span style="color: #007700">= </span><span style="color: #0000BB">date_parse</span><span style="color: #007700">(</span><span style="color: #DD0000">"2015-09-31"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">[</span><span style="color: #DD0000">"warnings"</span><span style="color: #007700">]);</span></span></code></div>
     </div>

     <p class="para">以上示例会输出：</p>
     <div class="example-contents screen">
<div class="annotation-interactive cdata"><pre>
array(1) {
  [11] =&gt;
  string(27) &quot;The parsed date was invalid&quot;
}
</pre></div>
     </div>
    </div>
   </p>
  </li>
  <li class="listitem">
   <p class="para">
    It is already possible to handle the edge cases, but then
    <span class="function"><a href="datetimeimmutable.createfromformat.php" class="function">DateTimeImmutable::createFromFormat()</a></span> must be used
    while supplying the correct format.
    <div class="informalexample">
     <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$res </span><span style="color: #007700">= </span><span style="color: #0000BB">DateTimeImmutable</span><span style="color: #007700">::</span><span style="color: #0000BB">createFromFormat</span><span style="color: #007700">(</span><span style="color: #DD0000">"Y-m-d"</span><span style="color: #007700">, </span><span style="color: #DD0000">"2015-09-34"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">);</span></span></code></div>
     </div>

     <p class="para">以上示例会输出：</p>
     <div class="example-contents screen">
<div class="annotation-interactive cdata"><pre>
object(DateTimeImmutable)#1 (3) {
  [&quot;date&quot;]=&gt;
  string(26) &quot;2015-10-04 17:24:43.000000&quot;
  [&quot;timezone_type&quot;]=&gt;
  int(3)
  [&quot;timezone&quot;]=&gt;
  string(13) &quot;Europe/London&quot;
}
</pre></div>
     </div>
    </div>
   </p>
  </li>
 </ol>

 
 <div id="datetime.formats.time" class="sect1">
  <h2 class="title">Time Formats</h2>

  <p class="para">
   This page describes the different date/time formats in a BNF-like syntax,
   that the <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span>,
   <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span>, <span class="function"><a href="function.date-create.php" class="function">date_create()</a></span>,
   <span class="function"><a href="function.date-create-immutable.php" class="function">date_create_immutable()</a></span>, and
   <span class="function"><a href="function.strtotime.php" class="function">strtotime()</a></span> parser understands.
  </p>
  <p class="para">
   To format <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span> and
   <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span> objects, please refer to the documentation
   of the <span class="function"><a href="datetime.format.php" class="function">DateTimeInterface::format()</a></span> method.
  </p>

  <table class="doctable table">
   <caption><strong>Used Symbols</strong></caption>
   
    <thead>
     <tr>
      <th>Description</th>
      <th>Formats</th>
      <th>Examples</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td><code class="literal">frac</code></td>
      <td>. [0-9]+</td>
      <td>&quot;.21342&quot;, &quot;.85&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">hh</code></td>
      <td>&quot;0&quot;?[1-9] | &quot;1&quot;[0-2]</td>
      <td>&quot;04&quot;, &quot;7&quot;, &quot;12&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">HH</code></td>
      <td>[01][0-9] | &quot;2&quot;[0-4]</td>
      <td>&quot;04&quot;, &quot;07&quot;, &quot;19&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">meridian</code></td>
      <td>[AaPp] .? [Mm] .? [\0\t ]</td>
      <td>&quot;A.m.&quot;, &quot;pM&quot;, &quot;am.&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">MM</code></td>
      <td>[0-5][0-9]</td>
      <td>&quot;00&quot;, &quot;12&quot;, &quot;59&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">II</code></td>
      <td>[0-5][0-9]</td>
      <td>&quot;00&quot;, &quot;12&quot;, &quot;59&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">space</code></td>
      <td>[ \t]</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><code class="literal">tz</code></td>
      <td>&quot;(&quot;? [A-Za-z]{1,6} &quot;)&quot;? | [A-Z][a-z]+([_/][A-Z][a-z]+)+</td>
      <td>&quot;CEST&quot;, &quot;Europe/Amsterdam&quot;, &quot;America/Indiana/Knox&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">tzcorrection</code></td>
      <td>&quot;GMT&quot;? [+-] <code class="literal">hh</code> &quot;:&quot;? <code class="literal">MM</code>?</td>
      <td>&quot;+0400&quot;, &quot;GMT-07:00&quot;, &quot;-07:00&quot;</td>
     </tr>

    </tbody>
   
  </table>


  <table class="doctable table">
   <caption><strong>12 Hour Notation</strong></caption>
   
    <thead>
     <tr>
      <th>Description</th>
      <th>Format</th>
      <th>Examples</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>Hour only, with meridian</td>
      <td><code class="literal">hh</code> <code class="literal">space</code>? <code class="literal">meridian</code></td>
      <td>&quot;4 am&quot;, &quot;5PM&quot;</td>
     </tr>

     <tr>
      <td>Hour and minutes, with meridian</td>
      <td><code class="literal">hh</code> [.:] <code class="literal">MM</code> <code class="literal">space</code>? <code class="literal">meridian</code></td>
      <td>&quot;4:08 am&quot;, &quot;7:19P.M.&quot;</td>
     </tr>

     <tr>
      <td>Hour, minutes and seconds, with meridian</td>
      <td><code class="literal">hh</code> [.:] <code class="literal">MM</code> [.:] <code class="literal">II</code> <code class="literal">space</code>? <code class="literal">meridian</code></td>
      <td>&quot;4:08:37 am&quot;, &quot;7:19:19P.M.&quot;</td>
     </tr>

     <tr>
      <td>MS SQL (Hour, minutes, seconds and fraction with meridian)</td>
      <td><code class="literal">hh</code> &quot;:&quot; <code class="literal">MM</code> &quot;:&quot; <code class="literal">II</code> [.:] [0-9]+ <code class="literal">meridian</code></td>
      <td>&quot;4:08:39:12313am&quot;</td>
     </tr>

    </tbody>
   
  </table>


  <table class="doctable table">
   <caption><strong>24 Hour Notation</strong></caption>
   
    <thead>
     <tr>
      <th>Description</th>
      <th>Format</th>
      <th>Examples</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>Hour and minutes</td>
      <td>&#039;t&#039;? <code class="literal">HH</code> [.:] <code class="literal">MM</code></td>
      <td>&quot;04:08&quot;, &quot;19.19&quot;, &quot;T23:43&quot;</td>
     </tr>

     <tr>
      <td>Hour and minutes, no colon</td>
      <td>&#039;t&#039;? <code class="literal">HH</code> <code class="literal">MM</code></td>
      <td>&quot;0408&quot;, &quot;t1919&quot;, &quot;T2343&quot;</td>
     </tr>

     <tr>
      <td>Hour, minutes and seconds</td>
      <td>&#039;t&#039;? <code class="literal">HH</code> [.:] <code class="literal">MM</code> [.:] <code class="literal">II</code></td>
      <td>&quot;04.08.37&quot;, &quot;t19:19:19&quot;</td>
     </tr>

     <tr>
      <td>Hour, minutes and seconds, no colon</td>
      <td>&#039;t&#039;? <code class="literal">HH</code> <code class="literal">MM</code> <code class="literal">II</code></td>
      <td>&quot;040837&quot;, &quot;T191919&quot;</td>
     </tr>

     <tr>
      <td>Hour, minutes, seconds and timezone</td>
      <td>&#039;t&#039;? <code class="literal">HH</code> [.:] <code class="literal">MM</code> [.:] <code class="literal">II</code> <code class="literal">space</code>? ( <code class="literal">tzcorrection</code> | <code class="literal">tz</code> )</td>
      <td>&quot;040837CEST&quot;, &quot;T191919-0700&quot;</td>
     </tr>

     <tr>
      <td>Hour, minutes, seconds and fraction</td>
      <td>&#039;t&#039;? <code class="literal">HH</code> [.:] <code class="literal">MM</code> [.:] <code class="literal">II</code> <code class="literal">frac</code></td>
      <td>&quot;04.08.37.81412&quot;, &quot;19:19:19.532453&quot;</td>
     </tr>

     <tr>
      <td>Time zone information</td>
      <td><code class="literal">tz</code> | <code class="literal">tzcorrection</code></td>
      <td>&quot;CEST&quot;, &quot;Europe/Amsterdam&quot;, &quot;+0430&quot;, &quot;GMT-06:00&quot;</td>
     </tr>

    </tbody>
   
  </table>

 </div>
 

 
 <div id="datetime.formats.date" class="sect1">
  <h2 class="title">Date Formats</h2>

  <p class="para">
   This page describes the different date formats in a BNF-like syntax, that
   the <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span>,
   <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span>, <span class="function"><a href="function.date-create.php" class="function">date_create()</a></span>,
   <span class="function"><a href="function.date-create-immutable.php" class="function">date_create_immutable()</a></span>, and
   <span class="function"><a href="function.strtotime.php" class="function">strtotime()</a></span> parser understands.
  </p>
  <p class="para">
   To format <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span> and
   <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span> objects, please refer to the documentation
   of the <span class="function"><a href="datetime.format.php" class="function">DateTimeInterface::format()</a></span> method.
  </p>

  <table class="doctable table">
   <caption><strong>Used Symbols</strong></caption>
   
    <thead>
     <tr>
      <th>Description</th>
      <th>Format</th>
      <th>Examples</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td><code class="literal">daysuf</code></td>
      <td>&quot;st&quot; | &quot;nd&quot; | &quot;rd&quot; | &quot;th&quot;</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><code class="literal">dd</code></td>
      <td>([0-2]?[0-9] | &quot;3&quot;[01]) <code class="literal">daysuf</code>?</td>
      <td>&quot;7th&quot;, &quot;22nd&quot;, &quot;31&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">DD</code></td>
      <td>&quot;0&quot; [0-9] | [1-2][0-9] | &quot;3&quot; [01]</td>
      <td>&quot;07&quot;, &quot;31&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">m</code></td>
      <td>&#039;january&#039; | &#039;february&#039; | &#039;march&#039; | &#039;april&#039; | &#039;may&#039; | &#039;june&#039; |
       &#039;july&#039; | &#039;august&#039; | &#039;september&#039; | &#039;october&#039; | &#039;november&#039; | &#039;december&#039; |
       &#039;jan&#039; | &#039;feb&#039; | &#039;mar&#039; | &#039;apr&#039; | &#039;may&#039; | &#039;jun&#039; | &#039;jul&#039; | &#039;aug&#039; | &#039;sep&#039; |
       &#039;sept&#039; | &#039;oct&#039; | &#039;nov&#039; | &#039;dec&#039; | &quot;I&quot; | &quot;II&quot; | &quot;III&quot; | &quot;IV&quot; | &quot;V&quot; | &quot;VI&quot;
       | &quot;VII&quot; | &quot;VIII&quot; | &quot;IX&quot; | &quot;X&quot; | &quot;XI&quot; | &quot;XII&quot;</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><code class="literal">M</code></td>
      <td>&#039;jan&#039; | &#039;feb&#039; | &#039;mar&#039; | &#039;apr&#039; | &#039;may&#039; | &#039;jun&#039; | &#039;jul&#039; | &#039;aug&#039; |
       &#039;sep&#039; | &#039;sept&#039; | &#039;oct&#039; | &#039;nov&#039; | &#039;dec&#039;</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><code class="literal">mm</code></td>
      <td>&quot;0&quot;? [0-9] | &quot;1&quot;[0-2]</td>
      <td>&quot;0&quot;, &quot;04&quot;, &quot;7&quot;, &quot;12&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">MM</code></td>
      <td>&quot;0&quot; [0-9] | &quot;1&quot;[0-2]</td>
      <td>&quot;00&quot;, &quot;04&quot;, &quot;07&quot;, &quot;12&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">y</code></td>
      <td>[0-9]{1,4}</td>
      <td>&quot;00&quot;, &quot;78&quot;, &quot;08&quot;, &quot;8&quot;, &quot;2008&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">yy</code></td>
      <td>[0-9]{2}</td>
      <td>&quot;00&quot;, &quot;08&quot;, &quot;78&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">YY</code></td>
      <td>[0-9]{4}</td>
      <td>&quot;2000&quot;, &quot;2008&quot;, &quot;1978&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">YYY</code></td>
      <td>[0-9]{5,19}</td>
      <td>&quot;81412&quot;, &quot;20192&quot;</td>
     </tr>

    </tbody>
   
  </table>


  <table class="doctable table">
   <caption><strong>Localized Notations</strong></caption>
   
    <thead>
     <tr>
      <th>Description</th>
      <th>Format</th>
      <th>Examples</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>American month and day</td>
      <td><code class="literal">mm</code> &quot;/&quot; <code class="literal">dd</code></td>
      <td>&quot;5/12&quot;, &quot;10/27&quot;</td>
     </tr>

     <tr>
      <td>American month, day and year</td>
      <td><code class="literal">mm</code> &quot;/&quot; <code class="literal">dd</code> &quot;/&quot; <code class="literal">y</code></td>
      <td>&quot;12/22/78&quot;, &quot;1/17/2006&quot;, &quot;1/17/6&quot;</td>
     </tr>

     <tr>
      <td>Four digit year, month and day with slashes</td>
      <td><code class="literal">YY</code> &quot;/&quot; <code class="literal">mm</code> &quot;/&quot; <code class="literal">dd</code></td>
      <td>&quot;2008/6/30&quot;, &quot;1978/12/22&quot;</td>
     </tr>

     <tr>
      <td>Four digit year and month (GNU)</td>
      <td><code class="literal">YY</code> &quot;-&quot; <code class="literal">mm</code></td>
      <td>&quot;2008-6&quot;, &quot;2008-06&quot;, &quot;1978-12&quot;</td>
     </tr>

     <tr>
      <td>Year, month and day with dashes</td>
      <td><code class="literal">y</code> &quot;-&quot; <code class="literal">mm</code> &quot;-&quot; <code class="literal">dd</code></td>
      <td>&quot;2008-6-30&quot;, &quot;78-12-22&quot;, &quot;8-6-21&quot;</td>
     </tr>

     <tr>
      <td>Day, month and four digit year, with dots, tabs or dashes</td>
      <td><code class="literal">dd</code> [.\t-] <code class="literal">mm</code> [.-] <code class="literal">YY</code></td>
      <td>&quot;30-6-2008&quot;, &quot;22.12.1978&quot;</td>
     </tr>

     <tr>
      <td>Day, month and two digit year, with dots or tabs</td>
      <td><code class="literal">dd</code> [.\t] <code class="literal">mm</code> &quot;.&quot; <code class="literal">yy</code></td>
      <td>&quot;30.6.08&quot;, &quot;22\t12.78&quot;</td>
     </tr>

     <tr>
      <td>Day, textual month and year</td>
      <td><code class="literal">dd</code> ([ \t.-])* <code class="literal">m</code> ([ \t.-])* <code class="literal">y</code></td>
      <td>&quot;30-June 2008&quot;, &quot;22DEC78&quot;, &quot;14 III 1879&quot;</td>
     </tr>

     <tr>
      <td>Textual month and four digit year (Day reset to 1)</td>
      <td><code class="literal">m</code> ([ \t.-])* <code class="literal">YY</code></td>
      <td>&quot;June 2008&quot;, &quot;DEC1978&quot;, &quot;March 1879&quot;</td>
     </tr>

     <tr>
      <td>Four digit year and textual month (Day reset to 1)</td>
      <td><code class="literal">YY</code> ([ \t.-])* <code class="literal">m</code></td>
      <td>&quot;2008 June&quot;, &quot;1978-XII&quot;, &quot;1879.MArCH&quot;</td>
     </tr>

     <tr>
      <td>Textual month, day and year</td>
      <td><code class="literal">m</code> ([ .\t-])* <code class="literal">dd</code> [,.stndrh\t ]+ <code class="literal">y</code></td>
      <td>&quot;July 1st, 2008&quot;, &quot;April 17, 1790&quot;, &quot;May.9,78&quot;</td>
     </tr>

     <tr>
      <td>Textual month and day</td>
      <td><code class="literal">m</code> ([ .\t-])* <code class="literal">dd</code> [,.stndrh\t ]*</td>
      <td>&quot;July 1st,&quot;, &quot;Apr 17&quot;, &quot;May.9&quot;</td>
     </tr>

     <tr>
      <td>Day and textual month</td>
      <td><code class="literal">dd</code> ([ .\t-])* <code class="literal">m</code></td>
      <td>&quot;1 July&quot;, &quot;17 Apr&quot;, &quot;9.May&quot;</td>
     </tr>

     <tr>
      <td>Month abbreviation, day and year</td>
      <td><code class="literal">M</code> &quot;-&quot; <code class="literal">DD</code> &quot;-&quot; <code class="literal">y</code></td>
      <td>&quot;May-09-78&quot;, &quot;Apr-17-1790&quot;</td>
     </tr>

     <tr>
      <td>Year, month abbreviation and day</td>
      <td><code class="literal">y</code> &quot;-&quot; <code class="literal">M</code> &quot;-&quot; <code class="literal">DD</code></td>
      <td>&quot;78-Dec-22&quot;, &quot;1814-MAY-17&quot;</td>
     </tr>

     <tr>
      <td>Year (and just the year)</td>
      <td><code class="literal">YY</code></td>
      <td>&quot;1978&quot;, &quot;2008&quot;</td>
     </tr>

     <tr>
      <td>Year (expanded, 5-19 digits with sign)</td>
      <td>[+-] <code class="literal">YYY</code></td>
      <td>&quot;-81120&quot;, &quot;+20192&quot;</td>
     </tr>

     <tr>
      <td>Textual month (and just the month)</td>
      <td><code class="literal">m</code></td>
      <td>&quot;March&quot;, &quot;jun&quot;, &quot;DEC&quot;</td>
     </tr>

    </tbody>
   
  </table>


  <table class="doctable table">
   <caption><strong>ISO8601 Notations</strong></caption>
   
    <thead>
     <tr>
      <th>Description</th>
      <th>Format</th>
      <th>Examples</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>Eight digit year, month and day</td>
      <td><code class="literal">YY</code> <code class="literal">MM</code> <code class="literal">DD</code></td>
      <td>&quot;15810726&quot;, &quot;19780417&quot;, &quot;18140517&quot;</td>
     </tr>

     <tr>
      <td>Four digit year, month and day with slashes</td>
      <td><code class="literal">YY</code> &quot;/&quot; <code class="literal">MM</code> &quot;/&quot; <code class="literal">DD</code></td>
      <td>&quot;2008/06/30&quot;, &quot;1978/12/22&quot;</td>
     </tr>

     <tr>
      <td>Two digit year, month and day with dashes</td>
      <td><code class="literal">yy</code> &quot;-&quot; <code class="literal">MM</code> &quot;-&quot; <code class="literal">DD</code></td>
      <td>&quot;08-06-30&quot;, &quot;78-12-22&quot;</td>
     </tr>

     <tr>
      <td>Four digit year with optional sign, month and day</td>
      <td>[+-]? <code class="literal">YY</code> &quot;-&quot; <code class="literal">MM</code> &quot;-&quot; <code class="literal">DD</code></td>
      <td>&quot;-0002-07-26&quot;, &quot;+1978-04-17&quot;, &quot;1814-05-17&quot;</td>
     </tr>

     <tr>
      <td>Five+ digit year with required sign, month and day</td>
      <td>[+-] <code class="literal">YYY</code> &quot;-&quot; <code class="literal">MM</code> &quot;-&quot; <code class="literal">DD</code></td>
      <td>&quot;-81120-02-26&quot;, &quot;+20192-04-17&quot;</td>
     </tr>

    </tbody>
   
  </table>


  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    For the <code class="literal">y</code> and <code class="literal">yy</code>
    formats, years below 100 are handled in a special way when the
    <code class="literal">y</code> or <code class="literal">yy</code> symbol is used.
    If the year falls in the range 0 (inclusive) to 69 (inclusive),
    2000 is added. If the year falls in the range 70 (inclusive) to
    99 (inclusive) then 1900 is added. This means that &quot;00-01-01&quot; is
    interpreted as &quot;2000-01-01&quot;.
   </p>
  </p></blockquote>

  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    The &quot;Day, month and two digit year, with dots or tabs&quot; format
    (<code class="literal">dd</code> [.\t] <code class="literal">mm</code> &quot;.&quot;
    <code class="literal">yy</code>) only works for the year values 61 (inclusive)
    to 99 (inclusive) - outside those years the <em>time
    format</em> &quot;<code class="literal">HH</code> [.:] <code class="literal">MM</code>
    [.:] <code class="literal">SS</code>&quot; has precedence.
   </p>
  </p></blockquote>

  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    The &quot;Year (and just the year)&quot; format only reliably works if a time string
    has already been found. Otherwise, if the four digit year matches
    <code class="literal">HH</code> <code class="literal">MM</code> then these two date elements
    are set instead.
   </p>
   <p class="para">
    To consistently parse just a year, use
    <span class="function"><a href="datetimeimmutable.createfromformat.php" class="function">DateTimeImmutable::createFromFormat()</a></span> with the
    <code class="literal">Y</code> specifier.
   </p>
  </p></blockquote>

  <div class="caution"><strong class="caution">警告</strong>
   <p class="para">
    It is possible to over- and underflow the <code class="literal">dd</code> and
    <code class="literal">DD</code> format. Day 0 means the last day of previous
    month, whereas overflows count into the next month. This makes
    &quot;2008-08-00&quot; equivalent to &quot;2008-07-31&quot; and &quot;2008-06-31&quot; equivalent
    to &quot;2008-07-01&quot; (June only has 30 days).
   </p>
   <p class="para">
    Note that the day range is restricted to 0-31 as indicated
    by the regular expression above. Thus &quot;2008-06-32&quot; is not a valid date
    string, for instance.
   </p>
   <p class="para">
    It is also possible to underflow the <code class="literal">mm</code> and
    <code class="literal">MM</code> formats with the value 0. A month value of
    0 means December of the previous year. As example &quot;2008-00-22&quot; is
    equivalent to &quot;2007-12-22&quot;.
   </p>
   <p class="para">
    If you combine the previous two facts and underflow both the day and
    the month, the following happens: &quot;2008-00-00&quot; first gets converted
    to &quot;2007-12-00&quot; which then gets converted to &quot;2007-11-30&quot;. This also
    happens with the string &quot;0000-00-00&quot;, which gets transformed into
    &quot;-0001-11-30&quot; (the year -1 in the ISO 8601 calendar, which is 2 BC
    in the proleptic Gregorian calendar).
   </p>
  </div>
 </div>
 

 
 <div id="datetime.formats.compound" class="sect1">
  <h2 class="title">Compound Formats</h2>

  <p class="para">
   This page describes the different compound date/time formats in a BNF-like
   syntax, that the <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span>,
   <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span>, <span class="function"><a href="function.date-create.php" class="function">date_create()</a></span>,
   <span class="function"><a href="function.date-create-immutable.php" class="function">date_create_immutable()</a></span>, and
   <span class="function"><a href="function.strtotime.php" class="function">strtotime()</a></span> parser understands.
  </p>
  <p class="para">
   To format <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span> and
   <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span> objects, please refer to the documentation
   of the <span class="function"><a href="datetime.format.php" class="function">DateTimeInterface::format()</a></span> method.
  </p>

  <table class="doctable table">
   <caption><strong>Used Symbols</strong></caption>
   
    <thead>
     <tr>
      <th>Description</th>
      <th>Formats</th>
      <th>Examples</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td><code class="literal">DD</code></td>
      <td>&quot;0&quot; [0-9] | [1-2][0-9] | &quot;3&quot; [01]</td>
      <td>&quot;02&quot;, &quot;12&quot;, &quot;31&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">doy</code></td>
      <td>&quot;00&quot;[1-9] | &quot;0&quot;[1-9][0-9] | [1-2][0-9][0-9] | &quot;3&quot;[0-5][0-9] | &quot;36&quot;[0-6]</td>
      <td>&quot;001&quot;, &quot;012&quot;, &quot;180&quot;, &quot;350&quot;, &quot;366&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">frac</code></td>
      <td>. [0-9]+</td>
      <td>&quot;.21342&quot;, &quot;.85&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">hh</code></td>
      <td>&quot;0&quot;?[1-9] | &quot;1&quot;[0-2]</td>
      <td>&quot;04&quot;, &quot;7&quot;, &quot;12&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">HH</code></td>
      <td>[01][0-9] | &quot;2&quot;[0-4]</td>
      <td>&quot;04&quot;, &quot;07&quot;, &quot;19&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">meridian</code></td>
      <td>[AaPp] .? [Mm] .? [\0\t ]</td>
      <td>&quot;A.m.&quot;, &quot;pM&quot;, &quot;am.&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">ii</code></td>
      <td>[0-5]?[0-9]</td>
      <td>&quot;04&quot;, &quot;8&quot;, &quot;59&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">II</code></td>
      <td>[0-5][0-9]</td>
      <td>&quot;04&quot;, &quot;08&quot;, &quot;59&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">M</code></td>
      <td>&#039;jan&#039; | &#039;feb&#039; | &#039;mar&#039; | &#039;apr&#039; | &#039;may&#039; | &#039;jun&#039; | &#039;jul&#039; | &#039;aug&#039; | &#039;sep&#039; | &#039;sept&#039; | &#039;oct&#039; | &#039;nov&#039; | &#039;dec&#039;</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><code class="literal">MM</code></td>
      <td>[0-1][0-9]</td>
      <td>&quot;00&quot;, &quot;12&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">space</code></td>
      <td>[ \t]</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td><code class="literal">ss</code></td>
      <td>([0-5]?[0-9])|60</td>
      <td>&quot;04&quot;, &quot;8&quot;, &quot;59&quot;, &quot;60&quot; (leap second)</td>
     </tr>

     <tr>
      <td><code class="literal">SS</code></td>
      <td>[0-5][0-9]</td>
      <td>&quot;04&quot;, &quot;08&quot;, &quot;59&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">W</code></td>
      <td>&quot;0&quot;[1-9] | [1-4][0-9] | &quot;5&quot;[0-3]</td>
      <td>&quot;05&quot;, &quot;17&quot;, &quot;53&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">tzcorrection</code></td>
      <td>&quot;GMT&quot;? [+-] <code class="literal">hh</code> &quot;:&quot;? <code class="literal">II</code>?</td>
      <td>&quot;+0400&quot;, &quot;GMT-07:00&quot;, &quot;-07:00&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">YY</code></td>
      <td>[0-9]{4}</td>
      <td>&quot;2000&quot;, &quot;2008&quot;, &quot;1978&quot;</td>
     </tr>

    </tbody>
   
  </table>


  <table class="doctable table">
   <caption><strong>Standards Formats</strong></caption>
   
    <thead>
     <tr>
      <th>Description</th>
      <th>Examples</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>ATOM</td>
      <td>&quot;2022-06-02T16:58:35+00:00&quot;</td>
     </tr>

     <tr>
      <td>COOKIE</td>
      <td>&quot;Thursday, 02-Jun-2022 16:58:35 UTC&quot;</td>
     </tr>

     <tr>
      <td>ISO8601</td>
      <td>&quot;2022-06-02T16:58:35+0000&quot;</td>
     </tr>

     <tr>
      <td><a href="https://datatracker.ietf.org/doc/html/rfc822" class="link external">&raquo;&nbsp;RFC 822</a></td>
      <td>&quot;Thu, 02 Jun 22 16:58:35 +0000&quot;</td>
     </tr>

     <tr>
      <td><a href="https://datatracker.ietf.org/doc/html/rfc850" class="link external">&raquo;&nbsp;RFC 850</a></td>
      <td>&quot;Thursday, 02-Jun-22 16:58:35 UTC&quot;</td>
     </tr>

     <tr>
      <td><a href="https://datatracker.ietf.org/doc/html/rfc1036" class="link external">&raquo;&nbsp;RFC 1036</a></td>
      <td>&quot;Thu, 02 Jun 22 16:58:35 +0000&quot;</td>
     </tr>

     <tr>
      <td><a href="https://datatracker.ietf.org/doc/html/rfc1123" class="link external">&raquo;&nbsp;RFC 1123</a></td>
      <td>&quot;Thu, 02 Jun 2022 16:58:35 +0000&quot;</td>
     </tr>

     <tr>
      <td><a href="https://datatracker.ietf.org/doc/html/rfc2822" class="link external">&raquo;&nbsp;RFC 2822</a></td>
      <td>&quot;Thu, 02 Jun 2022 16:58:35 +0000&quot;</td>
     </tr>

     <tr>
      <td><a href="https://datatracker.ietf.org/doc/html/rfc3339" class="link external">&raquo;&nbsp;RFC 3339</a></td>
      <td>&quot;2022-06-02T16:58:35+00:00&quot;</td>
     </tr>

     <tr>
      <td><a href="https://datatracker.ietf.org/doc/html/rfc3339" class="link external">&raquo;&nbsp;RFC 3339</a> Extended</td>
      <td>&quot;2022-06-02T16:58:35.698+00:00&quot;</td>
     </tr>

     <tr>
      <td><a href="https://datatracker.ietf.org/doc/html/rfc7231" class="link external">&raquo;&nbsp;RFC 7231</a></td>
      <td>&quot;Thu, 02 Jun 2022 16:58:35 GMT&quot;</td>
     </tr>

     <tr>
      <td>RSS</td>
      <td>&quot;Thu, 02 Jun 2022 16:58:35 +0000&quot;</td>
     </tr>

     <tr>
      <td>W3C</td>
      <td>&quot;2022-06-02T16:58:35+00:00&quot;</td>
     </tr>

    </tbody>
   
  </table>


  <table class="doctable table">
   <caption><strong>Localized Notations</strong></caption>
   
    <thead>
     <tr>
      <th>Description</th>
      <th>Format</th>
      <th>Examples</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>Common Log Format</td>
      <td><code class="literal">dd</code> &quot;/&quot; <code class="literal">M</code> &quot;/&quot; <code class="literal">YY</code> : <code class="literal">HH</code> &quot;:&quot; <code class="literal">II</code> &quot;:&quot; <code class="literal">SS</code> <code class="literal">space</code> <code class="literal">tzcorrection</code></td>
      <td>&quot;10/Oct/2000:13:55:36 -0700&quot;</td>
     </tr>

     <tr>
      <td>EXIF</td>
      <td><code class="literal">YY</code> &quot;:&quot; <code class="literal">MM</code> &quot;:&quot; <code class="literal">DD</code> &quot; &quot; <code class="literal">HH</code> &quot;:&quot; <code class="literal">II</code> &quot;:&quot; <code class="literal">SS</code></td>
      <td>&quot;2008:08:07 18:11:31&quot;</td>
     </tr>

     <tr>
      <td>ISO year with ISO week</td>
      <td><code class="literal">YY</code> &quot;-&quot;? &quot;W&quot; <code class="literal">W</code></td>
      <td>&quot;2008W27&quot;, &quot;2008-W28&quot;</td>
     </tr>

     <tr>
      <td>ISO year with ISO week and day</td>
      <td><code class="literal">YY</code> &quot;-&quot;? &quot;W&quot; <code class="literal">W</code> &quot;-&quot;? [0-7]</td>
      <td>&quot;2008W273&quot;, &quot;2008-W28-3&quot;</td>
     </tr>

     <tr>
      <td>MySQL</td>
      <td><code class="literal">YY</code> &quot;-&quot; <code class="literal">MM</code> &quot;-&quot; <code class="literal">DD</code> &quot; &quot; <code class="literal">HH</code> &quot;:&quot; <code class="literal">II</code> &quot;:&quot; <code class="literal">SS</code></td>
      <td>&quot;2008-08-07 18:11:31&quot;</td>
     </tr>

     <tr>
      <td>PostgreSQL: Year with day-of-year</td>
      <td><code class="literal">YY</code> &quot;.&quot;? <code class="literal">doy</code></td>
      <td>&quot;2008.197&quot;, &quot;2008197&quot;</td>
     </tr>

     <tr>
      <td>SOAP</td>
      <td><code class="literal">YY</code> &quot;-&quot; <code class="literal">MM</code> &quot;-&quot; <code class="literal">DD</code> &quot;T&quot; <code class="literal">HH</code> &quot;:&quot; <code class="literal">II</code> &quot;:&quot; <code class="literal">SS</code> <code class="literal">frac</code> <code class="literal">tzcorrection</code>?</td>
      <td>&quot;2008-07-01T22:35:17.02&quot;, &quot;2008-07-01T22:35:17.03+08:00&quot;</td>
     </tr>

     <tr>
      <td>Unix Timestamp</td>
      <td>&quot;@&quot; &quot;-&quot;? [0-9]+</td>
      <td>&quot;@1215282385&quot;</td>
     </tr>

     <tr>
      <td>Unix Timestamp with microseconds</td>
      <td>&quot;@&quot; &quot;-&quot;? [0-9]+ &quot;.&quot; [0-9]{0,6}</td>
      <td>&quot;@1607974647.503686&quot;</td>
     </tr>

     <tr>
      <td>XMLRPC</td>
      <td><code class="literal">YY</code> <code class="literal">MM</code> <code class="literal">DD</code> &quot;T&quot; <code class="literal">hh</code> &quot;:&quot; <code class="literal">II</code> &quot;:&quot; <code class="literal">SS</code></td>
      <td>&quot;20080701T22:38:07&quot;, &quot;20080701T9:38:07&quot;</td>
     </tr>

     <tr>
      <td>XMLRPC (Compact)</td>
      <td><code class="literal">YY</code> <code class="literal">MM</code> <code class="literal">DD</code> &#039;t&#039; <code class="literal">hh</code> <code class="literal">II</code> <code class="literal">SS</code></td>
      <td>&quot;20080701t223807&quot;, &quot;20080701T093807&quot;</td>
     </tr>

     <tr>
      <td>WDDX</td>
      <td><code class="literal">YY</code> &quot;-&quot; <code class="literal">mm</code> &quot;-&quot; <code class="literal">dd</code> &quot;T&quot; <code class="literal">hh</code> &quot;:&quot; <code class="literal">ii</code> &quot;:&quot; <code class="literal">ss</code></td>
      <td>&quot;2008-7-1T9:3:37&quot;</td>
     </tr>

    </tbody>
   
  </table>


  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    The &quot;W&quot; in the &quot;ISO year with ISO week&quot; and &quot;ISO year with ISO week
    and day&quot; formats is case-sensitive, you can only use the upper case
    &quot;W&quot;.
   </p>
   <p class="para">
    The &quot;T&quot; in the SOAP, XMLRPC and WDDX formats is case-sensitive, you
    can only use the upper case &quot;T&quot;.
   </p>
   <p class="para">
    The &quot;Unix Timestamp&quot; format sets the timezone to UTC.
   </p>
  </p></blockquote>
 </div>
 

 
 <div id="datetime.formats.relative" class="sect1">
  <h2 class="title">Relative Formats</h2>
  <p class="para">
   This page describes the different relative date/time formats in a BNF-like
   syntax, that the <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span>,
   <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span>, <span class="function"><a href="function.date-create.php" class="function">date_create()</a></span>,
   <span class="function"><a href="function.date-create-immutable.php" class="function">date_create_immutable()</a></span>, and
   <span class="function"><a href="function.strtotime.php" class="function">strtotime()</a></span> parser understands.
  </p>
  <p class="para">
   To format <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span> and
   <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span> objects, please refer to the documentation
   of the <span class="function"><a href="datetime.format.php" class="function">DateTimeInterface::format()</a></span> method.
  </p>

  <table class="doctable table">
   <caption><strong>Used Symbols</strong></caption>
   
    <thead>
     <tr>
      <th>Description</th>
      <th>Format</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td><code class="literal">dayname</code></td>
      <td>&#039;sunday&#039; | &#039;monday&#039; | &#039;tuesday&#039; | &#039;wednesday&#039; | &#039;thursday&#039; |
       &#039;friday&#039; | &#039;saturday&#039; | &#039;sun&#039; | &#039;mon&#039; | &#039;tue&#039; | &#039;wed&#039; | &#039;thu&#039; | &#039;fri&#039; |
       &#039;sat&#039;</td>
     </tr>

     <tr>
      <td><code class="literal">daytext</code></td>
      <td>&#039;weekday&#039; | &#039;weekdays&#039;</td>
     </tr>

     <tr>
      <td><code class="literal">number</code></td>
      <td>[+-]?[0-9]+</td>
     </tr>

     <tr>
      <td><code class="literal">ordinal</code></td>
      <td>&#039;first&#039; | &#039;second&#039; | &#039;third&#039; | &#039;fourth&#039; | &#039;fifth&#039; | &#039;sixth&#039; |
       &#039;seventh&#039; | &#039;eighth&#039; | &#039;ninth&#039; | &#039;tenth&#039; | &#039;eleventh&#039; | &#039;twelfth&#039; |
       &#039;next&#039; | &#039;last&#039; | &#039;previous&#039; | &#039;this&#039;</td>
     </tr>

     <tr>
      <td><code class="literal">reltext</code></td>
      <td>&#039;next&#039; | &#039;last&#039; | &#039;previous&#039; | &#039;this&#039;</td>
     </tr>

     <tr>
      <td><code class="literal">space</code></td>
      <td>[ \t]+</td>
     </tr>

     <tr>
      <td><code class="literal">unit</code></td>
      <td>&#039;ms&#039; | &#039;µs&#039; | (( &#039;msec&#039; | &#039;millisecond&#039; | &#039;µsec&#039; | &#039;microsecond&#039;
      | &#039;usec&#039; | &#039;sec&#039; | &#039;second&#039; | &#039;min&#039; | &#039;minute&#039; | &#039;hour&#039; | &#039;day&#039; |
      &#039;fortnight&#039; | &#039;forthnight&#039; | &#039;month&#039; | &#039;year&#039;) &#039;s&#039;?) | &#039;weeks&#039; |
      <code class="literal">daytext</code></td>
     </tr>

    </tbody>
   
  </table>


  <table class="doctable table">
   <caption><strong>Day-based Notations</strong></caption>
   
    <thead>
     <tr>
      <th>Format</th>
      <th>Description</th>
      <th>Examples</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>&#039;yesterday&#039;</td>
      <td>Midnight of yesterday</td>
      <td>&quot;yesterday 14:00&quot;</td>
     </tr>

     <tr>
      <td>&#039;midnight&#039;</td>
      <td>The time is set to 00:00:00</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td>&#039;today&#039;</td>
      <td>The time is set to 00:00:00</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td>&#039;now&#039;</td>
      <td>Now - this is simply ignored</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td>&#039;noon&#039;</td>
      <td>The time is set to 12:00:00</td>
      <td>&quot;yesterday noon&quot;</td>
     </tr>

     <tr>
      <td>&#039;tomorrow&#039;</td>
      <td>Midnight of tomorrow</td>
      <td class="empty">&nbsp;</td>
     </tr>

     <tr>
      <td>&#039;back of&#039; <code class="literal">hour</code></td>
      <td>15 minutes past the specified hour</td>
      <td>&quot;back of 7pm&quot;, &quot;back of 15&quot;</td>
     </tr>

     <tr>
      <td>&#039;front of&#039; <code class="literal">hour</code></td>
      <td>15 minutes before the specified hour</td>
      <td>&quot;front of 5am&quot;, &quot;front of 23&quot;</td>
     </tr>

     <tr>
      <td>&#039;first day of&#039;</td>
      <td>Sets the day of the first of the current month. This phrase is
       usually best used together with a month name following it as it only
       effects the current month</td>
      <td>&quot;first day of January 2008&quot;</td>
     </tr>

     <tr>
      <td>&#039;last day of&#039;</td>
      <td>Sets the day to the last day of the current month. This phrase is
       usually best used together with a month name following it as it only
       effects the current month</td>
      <td>&quot;last day of next month&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">ordinal</code> <code class="literal">space</code> <code class="literal">dayname</code> <code class="literal">space</code> &#039;of&#039;</td>
      <td>Calculates the <code class="literal">x</code>-th week day of the current month.</td>
      <td>&quot;first sat of July 2008&quot;</td>
     </tr>

     <tr>
      <td>&#039;last&#039; <code class="literal">space</code> <code class="literal">dayname</code> <code class="literal">space</code> &#039;of&#039;</td>
      <td>Calculates the <em>last</em> week day of the current month.</td>
      <td>&quot;last sat of July 2008&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">number</code> <code class="literal">space</code>? (<code class="literal">unit</code> | &#039;week&#039;)</td>
      <td>Handles relative time items where the value is a number.</td>
      <td>&quot;+5 weeks&quot;, &quot;12 day&quot;, &quot;-7 weekdays&quot;</td>
     </tr>

     <tr>
      <td>(<code class="literal">ordinal</code> | <code class="literal">reltext</code>) <code class="literal">space</code> <code class="literal">unit</code></td>
      <td>Handles relative time items where the value is text.
      <code class="literal">last</code> and <code class="literal">previous</code> are equivalent
      to <code class="literal">-1</code>, <code class="literal">this</code> to nothing, and
      <code class="literal">next</code> to <code class="literal">+1</code>.</td>
      <td>&quot;fifth day&quot;, &quot;second month&quot;, &quot;last day&quot;, &quot;previous year&quot;</td>
     </tr>

     <tr>
      <td>&#039;ago&#039;</td>
      <td>Negates all the values of previously found relative time items.</td>
      <td>&quot;2 days ago&quot;, &quot;8 days ago 14:00&quot;, &quot;2 months 5 days ago&quot;, &quot;2 months ago 5 days&quot;, &quot;2 days ago&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">dayname</code></td>
      <td>
       Moves to the next day of this name. (See <a href="datetime.formats.php#datetime.formats.relative.dayname-note" class="link">note</a>)
      </td>
      <td>&quot;Monday&quot;</td>
     </tr>

     <tr>
      <td><code class="literal">reltext</code> <code class="literal">space</code> &#039;week&#039;</td>
      <td>Handles the special format &quot;weekday + last/this/next week&quot;.</td>
      <td>&quot;Monday next week&quot;</td>
     </tr>

    </tbody>
   
  </table>


  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    Relative statements are always processed <em>after</em>
    non-relative statements. This makes &quot;+1 week july 2008&quot; and &quot;july
    2008 +1 week&quot; equivalent.
   </p>
   <p class="para">
    Exceptions to this rule are: &quot;yesterday&quot;, &quot;midnight&quot;, &quot;today&quot;, &quot;noon&quot;
    and &quot;tomorrow&quot;. Note that &quot;tomorrow 11:00&quot; and &quot;11:00 tomorrow&quot;
    are different. Considering today&#039;s date of &quot;July 23rd, 2008&quot; the
    first one produces &quot;2008-07-24 11:00&quot; where as the second one
    produces &quot;2008-07-24 00:00&quot;. The reason for this is that those
    five statements directly influence the current time.
   </p>
   <p class="para">
    Keywords such as &quot;first day of&quot; depend on the context in which the
    relative format string is used. If used with a static method or function,
    the referent is the current system timestamp. However, if used in
    <span class="function"><a href="datetime.modify.php" class="function">DateTime::modify()</a></span> or
    <span class="function"><a href="datetimeimmutable.modify.php" class="function">DateTimeImmutable::modify()</a></span>, the referent is the object
    on which the <code class="literal">modify()</code> method is called.
   </p>
  </p></blockquote>

  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para" id="datetime.formats.relative.dayname-note">
    Observe the following remarks when the current day-of-week is the
    same as the day-of-week used in the date/time string. The current
    day-of-week could have been (re-)calculated by non-relative parts of
    the date/time string however.
   </p>
   <ol type="1">
    <li class="listitem">
     <span class="simpara">
      &quot;<code class="literal">dayname</code>&quot; does <em>not</em> advance to
      another day. (Example: &quot;Wed July 23rd, 2008&quot; means &quot;2008-07-23&quot;).
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;<code class="literal">number</code> <code class="literal">dayname</code>&quot; does
      <em>not</em> advance to another day. (Example: &quot;1
      wednesday july 23rd, 2008&quot; means &quot;2008-07-23&quot;).
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;<code class="literal">number</code> week <code class="literal">dayname</code>&quot; will
      first add the number of weeks, but does <em>not</em>
      advance to another day. In this case &quot;<code class="literal">number</code>
      week&quot; and &quot;<code class="literal">dayname</code>&quot; are two distinct blocks.
      (Example: &quot;+1 week wednesday july 23rd, 2008&quot; means &quot;2008-07-30&quot;).
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;<code class="literal">ordinal</code> <code class="literal">dayname</code>&quot;
      <em>does</em> advance to another day. (Example &quot;first
      wednesday july 23rd, 2008&quot; means &quot;2008-07-30&quot;).
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;<code class="literal">number</code> week <code class="literal">ordinal</code>
      <code class="literal">dayname</code>&quot; will first add the number of
      weeks, and then <em>advances</em> to another
      day. In this case &quot;<code class="literal">number</code> week&quot; and
      &quot;<code class="literal">ordinal</code> <code class="literal">dayname</code>&quot; are two
      distinct blocks. (Example: &quot;+1 week first wednesday july 23rd,
      2008&quot; means &quot;2008-08-06&quot;).
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;<code class="literal">ordinal</code> <code class="literal">dayname</code> &#039;of&#039; &quot;
      does <em>not</em> advance to another day. (Example:
      &quot;first wednesday of july 23rd, 2008&quot; means &quot;2008-07-02&quot; because
      the specific phrase with &#039;of&#039; resets the day-of-month to &#039;1&#039; and
      the &#039;23rd&#039; is ignored here).
     </span>
    </li>
   </ol>
   <p class="para">
    Also observe that the &quot;of&quot; in &quot;<code class="literal">ordinal</code>
    <code class="literal">space</code> <code class="literal">dayname</code>
    <code class="literal">space</code> &#039;of&#039; &quot; and &quot;&#039;last&#039; <code class="literal">space</code>
    <code class="literal">dayname</code> <code class="literal">space</code> &#039;of&#039; &quot; does
    something special.
   </p>
   <ol type="1">
    <li class="listitem">
     <span class="simpara">
      It sets the day-of-month to 1.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;<code class="literal">ordinal</code> <code class="literal">dayname</code> &#039;of&#039; &quot; does
      <em>not</em> advance to another day. (Example: &quot;first
      tuesday of july 2008&quot; means &quot;2008-07-01&quot;).
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;<code class="literal">ordinal</code> <code class="literal">dayname</code> &quot;
      <em>does</em> advance to another day. (Example: &quot;first
      tuesday july 2008&quot; means &quot;2008-07-08&quot;, see also point 4 in the
      list above).
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;&#039;last&#039; <code class="literal">dayname</code> &#039;of&#039; &quot; takes the last
      <code class="literal">dayname</code> of the current month. (Example: &quot;last
      wed of july 2008&quot; means &quot;2008-07-30&quot;)
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;&#039;last&#039; <code class="literal">dayname</code>&quot; takes the last
      <code class="literal">dayname</code> from the current day. (Example: &quot;last
      wed july 2008&quot; means &quot;2008-06-25&quot;; &quot;july 2008&quot; first sets the
      current date to &quot;2008-07-01&quot; and then &quot;last wed&quot; moves to the
      previous Wednesday which is &quot;2008-06-25&quot;).
     </span>
    </li>
   </ol>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    Relative month values are calculated based on the length of months that
    they pass through. An example would be &quot;+2 month 2011-11-30&quot;, which would
    produce &quot;2012-01-30&quot;. This is due to November being 30 days in length, and
    December being 31 days in length, producing a total of 61 days.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    <code class="literal">number</code> is an <em>integer</em> number; if a
    decimal number is given, the dot (or comma) is likely interpreted as delimiter.
    For instance, <code class="literal">&#039;+1.5 hours&#039;</code> is parsed like
    <code class="literal">&#039;+1 5 hours&#039;</code>, not as <code class="literal">&#039;+1 hour +30 minutes&#039;</code>.
   </p>
  </p></blockquote>

  <div class="sect2">
   <h3 class="title">更新日志</h3>
   <p class="para">
    <table class="doctable informaltable">
     
      <thead>
       <tr>
        <th>版本</th>
        <th>说明</th>
       </tr>

      </thead>

      <tbody class="tbody">
       <tr>
        <td>8.4.0</td>
        <td>
         <code class="literal">number</code> now again accepts a plus sign followed by a
         minus sign, e.g. <code class="literal">+-2</code>, and other combinations of
         multiple signs.
        </td>
       </tr>

       <tr>
        <td>8.2.0</td>
        <td>
         <code class="literal">number</code> no longer accepts a plus sign followed by a
         minus sign, e.g. <code class="literal">+-2</code>.
        </td>
       </tr>

       <tr>
        <td>7.0.8</td>
        <td>
         Weeks always start on monday. Formerly, sunday would also be considered
         to start a week.
        </td>
       </tr>

      </tbody>
     
    </table>

   </p>
  </div>
 </div>
 

</div>
<?php manual_footer($setup); ?>