<?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 => 'ru',
  ),
  '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' => 'ru',
    '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>; набор поддерживаемых символов
       форматирования зависит от ОС и С-библиотеки.
      </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-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>Месяцы после января (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-го января (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 /><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">
    Внутренне эта функция вызывает функцию <code class="literal">strptime()</code>
    системной библиотеки на языке C. Поведение функции в одной операционной системе
    иногда значительно отличается от поведения в другой. Функция <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> включает високосные секунды — до двух в год.
    Подробнее о високосных секунды рассказывает статья
    <a href="http://en.wikipedia.org/wiki/Leap_second" class="link external">&raquo;&nbsp;о високосной секунде</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); ?>