<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.strptime.php',
    1 => 'strptime',
    2 => 'strftime が生成した日付/時刻をパースする',
  ),
  'up' => 
  array (
    0 => 'ref.datetime.php',
    1 => '日付・時刻 関数',
  ),
  'prev' => 
  array (
    0 => 'function.strftime.php',
    1 => 'strftime',
  ),
  'next' => 
  array (
    0 => 'function.strtotime.php',
    1 => 'strtotime',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    '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> で使用されていたものと同じ）。
        <span class="function"><a href="function.strftime.php" class="function">strftime()</a></span> で使えるオプションの中には、
        <span class="function"><strong>strptime()</strong></span> では何の影響を及ぼさないものがあることに注意しましょう。
        実際にサポートする範囲がどのようになるのかは、
        使っている OS と C ライブラリに依存します。
       </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><code class="literal">&quot;tm_sec&quot;</code></td>
         <td>分未満の秒数 (0-61)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;tm_min&quot;</code></td>
         <td>時間未満の分数 (0-59)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;tm_hour&quot;</code></td>
         <td>0 時以降の時間数 (0-23)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;tm_mday&quot;</code></td>
         <td>月内の日数 (1-31)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;tm_mon&quot;</code></td>
         <td>1 月から数えた月数 (0-11)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;tm_year&quot;</code></td>
         <td>1900 年以降の年</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;tm_wday&quot;</code></td>
         <td>日曜日からの日数 (0-6)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;tm_yday&quot;</code></td>
         <td>1 月 1 日からの日数 (0-365)</td>
        </tr>

        <tr>
         <td><code class="literal">&quot;unparsed&quot;</code></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">
    内部では、この関数はシステムの C ライブラリ関数
    <code class="literal">strptime()</code> をコールしています。
    このライブラリ関数は、OS によって挙動が異なることがあります。
    <span class="function"><a href="function.date-parse-from-format.php" class="function">date_parse_from_format()</a></span>
    はこの問題の影響を受けないので、
    <span class="function"><a href="function.date-parse-from-format.php" class="function">date_parse_from_format()</a></span> を使うことを推奨します。
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    <code class="literal">&quot;tm_sec&quot;</code> には、うるう秒も組み込まれています (現在は、年間
    2 秒まで)。うるう秒についての詳細な情報は <a href="http://en.wikipedia.org/wiki/Leap_second" class="link external">&raquo;&nbsp;Wikipedia
    の記事</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> - 文字列をパースしてタイムスタンプにする</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> - 指定した書式でフォーマットされた日付についての情報を取得する</span></li>
   </ul>
  </p>
 </div>

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