<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.datetime.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.strptime.php',
    1 => 'strptime',
    2 => '解析由 strftime 生成的日期／时间',
  ),
  'up' => 
  array (
    0 => 'ref.datetime.php',
    1 => 'Date/Time 函数',
  ),
  'prev' => 
  array (
    0 => 'function.strftime.php',
    1 => 'strftime',
  ),
  'next' => 
  array (
    0 => 'function.strtotime.php',
    1 => 'strtotime',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/datetime/functions/strptime.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.strptime" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">strptime</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">strptime</span> &mdash; <span class="dc-title">
   解析由 <span class="function"><a href="function.strftime.php" class="function">strftime()</a></span> 生成的日期／时间
  </span></p>

 </div>

 <div id="function.strptime-refsynopsisdiv">
  <div class="warning"><strong class="warning">警告</strong><p class="simpara">此函数自 PHP 8.1.0 
起<em>弃用</em>。强烈建议不要应用此函数。</p></div>
 </div>

 <div class="refsect1 description" id="refsect1-function.strptime-description">
   <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="attribute"><a href="class.deprecated.php">#[\Deprecated]</a> </span><br>
   <span class="methodname"><strong>strptime</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$timestamp</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$format</code></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>strptime()</strong></span> 返回一个将
   <code class="parameter">timestamp</code> 解析后的数组，如果出错返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
  <p class="para">
   月份和星期几的名字以及其它与语种有关的字符串对应于
   <span class="function"><a href="function.setlocale.php" class="function">setlocale()</a></span>设定的当前区域（<strong><code><a href="string.constants.php#constant.lc-time">LC_TIME</a></code></strong>）。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.strptime-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">timestamp</code>（<span class="type"><a href="language.types.string.php" class="type string">string</a></span>）</dt>
     <dd>
      <p class="para">
       被解析的字符串（例如从 <span class="function"><a href="function.strftime.php" class="function">strftime()</a></span> 返回的）
      </p>
     </dd>
    
    
     <dt><code class="parameter">format</code>（<span class="type"><a href="language.types.string.php" class="type string">string</a></span>）</dt>
     <dd>
      <p class="para">
       <code class="parameter">timestamp</code> 所使用的格式（例如同
       <span class="function"><a href="function.strftime.php" class="function">strftime()</a></span> 中所使用的相同）。
      </p>
      <p class="para">
       更多有关格式选项的信息见 <span class="function"><a href="function.strftime.php" class="function">strftime()</a></span> 页面。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.strptime-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回一个数组 或者在失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>
  </p>

  <p class="para">
   <table class="doctable table">
    <caption><strong>数组中包含以下单元</strong></caption>
    
     <thead>
      <tr>
       <th>键名</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>tm_sec</td>
       <td>当前分钟内的秒数（0-61）</td>
      </tr>

      <tr>
       <td>tm_min</td>
       <td>当前小时内的分钟数（0-59）</td>
      </tr>

      <tr>
       <td>tm_hour</td>
       <td>午夜起的小时数（0-23）</td>
      </tr>

      <tr>
       <td>tm_mday</td>
       <td>月份中的第几天（1-31）</td>
      </tr>

      <tr>
       <td>tm_mon</td>
       <td>自一月起过了几个月（0-11）</td>
      </tr>

      <tr>
       <td>tm_year</td>
       <td>自 1900 年起过了几年</td>
      </tr>

      <tr>
       <td>tm_wday</td>
       <td>自星期天起过了几天（0-6）</td>
      </tr>

      <tr>
       <td>tm_yday</td>
       <td>本年自一月一日起过了多少天（0-365）</td>
      </tr>

      <tr>
       <td>unparsed</td>
       <td><code class="parameter">timestamp</code> 中未能通过指定的
       <code class="parameter">format</code> 识别的部分</td>
      </tr>

     </tbody>
    
   </table>

  </p>

 </div>


 <div class="refsect1 changelog" id="refsect1-function.strptime-changelog">
  <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.1.0</td>
       <td>
        此函数已弃用。改用 <span class="function"><a href="function.date-parse-from-format.php" class="function">date_parse_from_format()</a></span>（用于单独区域设置解析）或者 <span class="methodname"><a href="intldateformatter.parse.php" class="methodname">IntlDateFormatter::parse()</a></span>（用于依赖区域设置解析）
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.strptime-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 <span class="function"><strong>strptime()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$format </span><span style="color: #007700">= </span><span style="color: #DD0000">'%d/%m/%Y %H:%M:%S'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$strf </span><span style="color: #007700">= </span><span style="color: #0000BB">strftime</span><span style="color: #007700">(</span><span style="color: #0000BB">$format</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$strf</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">strptime</span><span style="color: #007700">(</span><span style="color: #0000BB">$strf</span><span style="color: #007700">, </span><span style="color: #0000BB">$format</span><span style="color: #007700">));</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">03/10/2004 15:54:19

Array
(
    [tm_sec] =&gt; 19
    [tm_min] =&gt; 54
    [tm_hour] =&gt; 15
    [tm_mday] =&gt; 3
    [tm_mon] =&gt; 9
    [tm_year] =&gt; 104
    [tm_wday] =&gt; 0
    [tm_yday] =&gt; 276
    [unparsed] =&gt;
)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.strptime-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: <span class="simpara">此函数未在 Windows 平台下实现。</span></p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    Internally, this function calls the <code class="literal">strptime()</code>
    function provided by the system&#039;s C library. This function can exhibit
    noticeably different behaviour across different operating systems. The
    use of <span class="function"><a href="function.date-parse-from-format.php" class="function">date_parse_from_format()</a></span>, which does not
    suffer from these issues, is recommended.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    <code class="literal">&quot;tm_sec&quot;</code> includes any leap seconds (currently upto 2
    a year). For more information on leap seconds, see the <a href="http://en.wikipedia.org/wiki/Leap_second" class="link external">&raquo;&nbsp;Wikipedia article
    on leap seconds</a>.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.strptime-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="intldateformatter.parse.php" class="methodname" rel="rdfs-seeAlso">IntlDateFormatter::parse()</a> - Parse string to a timestamp value</span></li>
    <li><span class="methodname"><a href="datetime.createfromformat.php" class="methodname" rel="rdfs-seeAlso">DateTime::createFromFormat()</a> - 根据指定格式解析时间字符串</span></li>
    <li><span class="function"><a href="function.checkdate.php" class="function" rel="rdfs-seeAlso">checkdate()</a> - 验证一个格里高里日期</span></li>
    <li><span class="function"><a href="function.strftime.php" class="function" rel="rdfs-seeAlso">strftime()</a> - 根据区域设置格式化本地时间/日期</span></li>
    <li><span class="function"><a href="function.date-parse-from-format.php" class="function" rel="rdfs-seeAlso">date_parse_from_format()</a> - Get info about given date formatted according to the specified format</span></li>
   </ul>
  </p>
 </div>

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