<?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 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.strtotime.php',
    1 => 'strtotime',
    2 => 'Parse about any English textual datetime description into a Unix timestamp',
  ),
  'up' => 
  array (
    0 => 'ref.datetime.php',
    1 => 'Функції Дати/часу',
  ),
  'prev' => 
  array (
    0 => 'function.strptime.php',
    1 => 'strptime',
  ),
  'next' => 
  array (
    0 => 'function.time.php',
    1 => 'time',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/datetime/functions/strtotime.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.strtotime" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">strtotime</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">strtotime</span> &mdash; <span class="dc-title">Parse about any English textual datetime description into a Unix timestamp</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.strtotime-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>strtotime</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$datetime</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$baseTimestamp</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="simpara">
   The function expects to be given a string containing an English date format
   and will try to parse that format into a Unix timestamp (the number of
   seconds since January 1 1970 00:00:00 UTC), relative to the timestamp given
   in <code class="parameter">baseTimestamp</code>, or the current time if
   <code class="parameter">baseTimestamp</code> is not supplied.  The date string parsing
   is defined in <a href="datetime.formats.php" class="link">Date and Time Formats</a>, and
   has several subtle considerations.  Reviewing the full details there is strongly
   recommended.
  </p>
  <div class="warning"><strong class="warning">Увага</strong>
   <p class="para">
    The Unix timestamp that this function returns does not contain information
    about time zones. In order to do calculations with date/time information,
    you should use the more capable <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span>.
   </p>
  </div>
  <p class="para">
   Each parameter of this function uses the default time zone unless a
   time zone is specified in that parameter.  Be careful not to use
   different time zones in each parameter unless that is intended.
   See <span class="function"><a href="function.date-default-timezone-get.php" class="function">date_default_timezone_get()</a></span> on the various
   ways to define the default time zone.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.strtotime-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">datetime</code></dt>
     <dd>
      <p class="para">Рядок дати/часу. Пояснення коректних форматів надано в <a href="datetime.formats.php" class="link">Формати дати й часу</a>.</p>
     </dd>
    
    
     <dt><code class="parameter">baseTimestamp</code></dt>
     <dd>
      <p class="para">
       The timestamp which is used as a base for the calculation of relative
       dates.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.strtotime-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns a timestamp on success, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> otherwise.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.strtotime-errors">
  <h3 class="title">Помилки/виключення</h3>
   
   <p class="para">
Якщо часовий пояс хибний, то під час кожного виклику функції дати/часу
виникатиме <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>. Див.
<span class="function"><a href="function.date-default-timezone-set.php" class="function">date_default_timezone_set()</a></span>.</p>
 
 </div>


 <div class="refsect1 changelog" id="refsect1-function.strtotime-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.0.0</td>
       <td>
        <code class="parameter">baseTimestamp</code> is nullable now.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.strtotime-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 A <span class="function"><strong>strtotime()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"now"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"10 September 2000"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"+1 day"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"+1 week"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"+1 week 2 days 4 hours 2 seconds"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"next Thursday"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"last Monday"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Приклад #2 Checking for failure</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$str </span><span style="color: #007700">= </span><span style="color: #DD0000">'Not Good'</span><span style="color: #007700">;<br /><br />if ((</span><span style="color: #0000BB">$timestamp </span><span style="color: #007700">= </span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">)) === </span><span style="color: #0000BB">false</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"The string (</span><span style="color: #0000BB">$str</span><span style="color: #DD0000">) is bogus"</span><span style="color: #007700">;<br />} else {<br />    echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$str</span><span style="color: #DD0000"> == " </span><span style="color: #007700">. </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'l dS \o\f F Y h:i:s A'</span><span style="color: #007700">, </span><span style="color: #0000BB">$timestamp</span><span style="color: #007700">);<br />}</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.strtotime-notes">
  <h3 class="title">Примітки</h3>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    &quot;Relative&quot; date in this case also means that if a particular component
    of the date/time stamp is not provided, it will be taken verbatim from
    the <code class="parameter">baseTimestamp</code>.  That is, <code class="code">strtotime(&#039;February&#039;)</code>,
    if run on the 31st of May 2022, will be interpreted as <code class="literal">31 February 2022</code>,
    which will overflow into a timestamp on <code class="literal">3 March</code>.
    (In a leap year, it would be <code class="literal">2 March</code>.)  Using
    <code class="code">strtotime(&#039;1 February&#039;)</code> or <code class="code">strtotime(&#039;first day of February&#039;)</code>
    would avoid that problem.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    If the number of the year is specified in a two digit format, the values
    between 00-69 are mapped to 2000-2069 and 70-99 to 1970-1999. See the notes
    below for possible differences on 32bit systems (possible dates might end on 
    2038-01-19 03:14:07).
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    The valid range of a timestamp is typically from Fri, 13 Dec
    1901 20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC. (These are
    the dates that correspond to the minimum and maximum values for
    a 32-bit signed integer.)
   </p>
   <p class="para">
    For 64-bit versions of PHP, the valid range of a timestamp is effectively
    infinite, as 64 bits can represent approximately 293 billion years in either
    direction.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    Using this function for mathematical operations is not advisable.
    It is better to use <span class="methodname"><a href="datetime.add.php" class="methodname">DateTime::add()</a></span> and
    <span class="methodname"><a href="datetime.sub.php" class="methodname">DateTime::sub()</a></span>.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.strtotime-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span></li>
    <li><span class="methodname"><a href="datetimeimmutable.createfromformat.php" class="methodname" rel="rdfs-seeAlso">DateTimeImmutable::createFromFormat()</a> - Parses a time string according to a specified format</span></li>
    <li><a href="datetime.formats.php" class="link">Date and Time Formats</a></li>
    <li><span class="function"><a href="function.checkdate.php" class="function" rel="rdfs-seeAlso">checkdate()</a> - Validate a Gregorian date</span></li>
    <li><span class="function"><a href="function.strptime.php" class="function" rel="rdfs-seeAlso">strptime()</a> - Parse a time/date generated with strftime</span></li>
   </ul>
  </p>
 </div>

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