<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.datetimeimmutable.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'datetimeimmutable.getlasterrors.php',
    1 => 'DateTimeImmutable::getLastErrors',
    2 => 'Returns the warnings and errors',
  ),
  'up' => 
  array (
    0 => 'class.datetimeimmutable.php',
    1 => 'DateTimeImmutable',
  ),
  'prev' => 
  array (
    0 => 'datetimeimmutable.createfrommutable.php',
    1 => 'DateTimeImmutable::createFromMutable',
  ),
  'next' => 
  array (
    0 => 'datetimeimmutable.modify.php',
    1 => 'DateTimeImmutable::modify',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/datetime/datetimeimmutable/getlasterrors.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="datetimeimmutable.getlasterrors" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DateTimeImmutable::getLastErrors</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">DateTimeImmutable::getLastErrors</span> &mdash; <span class="dc-title">Returns the warnings and errors</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-datetimeimmutable.getlasterrors-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>DateTimeImmutable::getLastErrors</strong></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">
   Returns an array of warnings and errors found while parsing
   a date/time string.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-datetimeimmutable.getlasterrors-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">У цієї функції немає
параметрів.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-datetimeimmutable.getlasterrors-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns array containing info about warnings and errors, or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if there
   are neither warnings nor errors.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-datetimeimmutable.getlasterrors-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.2.0</td>
       <td>
        Before PHP 8.2.0, this function did not return <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>
        when there were no warnings or errors. Instead, it would always
        return the documented array structure.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-datetimeimmutable.getlasterrors-examples">
  <h3 class="title">Приклади</h3>
  <div class="example" id="example-1">
   <p><strong>Приклад #1 <span class="function"><strong>DateTimeImmutable::getLastErrors()</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">try {<br />    </span><span style="color: #0000BB">$date </span><span style="color: #007700">= new </span><span style="color: #0000BB">DateTimeImmutable</span><span style="color: #007700">(</span><span style="color: #DD0000">'asdfasdf'</span><span style="color: #007700">);<br />} catch (</span><span style="color: #0000BB">Exception $e</span><span style="color: #007700">) {<br />    </span><span style="color: #FF8000">// For demonstration purposes only...<br />    </span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">DateTimeImmutable</span><span style="color: #007700">::</span><span style="color: #0000BB">getLastErrors</span><span style="color: #007700">());<br /><br />    </span><span style="color: #FF8000">// The real object-oriented way to do this is<br />    </span><span style="color: #007700">echo </span><span style="color: #0000BB">$e</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getMessage</span><span style="color: #007700">();<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>Поданий вище приклад
виведе:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Array
(
    [warning_count] =&gt; 1
    [warnings] =&gt; Array
        (
            [6] =&gt; Double timezone specification
        )

    [error_count] =&gt; 1
    [errors] =&gt; Array
        (
            [0] =&gt; The timezone could not be found in the database
        )
)
Failed to parse time string (asdfasdf) at position 0 (a): The timezone could not be found in the database</pre>
</div>
   </div>
   <div class="example-contents"><p>
    The indexes 6, and 0 in the example output refer to the character index in the string where the error occurred.
   </p></div>
  </div>
  <div class="example" id="example-2">
   <p><strong>Приклад #2 Detecting rolled over dates</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$date </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">'2020-02-30'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">DateTimeImmutable</span><span style="color: #007700">::</span><span style="color: #0000BB">getLastErrors</span><span style="color: #007700">());</span></span></code></div>
   </div>

   <div class="example-contents"><p>Поданий вище приклад
виведе:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Array
(
    [warning_count] =&gt; 1
    [warnings] =&gt; Array
        (
            [10] =&gt; The parsed date was invalid
        )

    [error_count] =&gt; 0
    [errors] =&gt; Array
        (
        )
)</pre>
</div>
   </div>
  </div>
 </div>



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