<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.datetime.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'datetime.construct.php',
    1 => 'DateTime::__construct',
    2 => 'Returns new DateTime object',
  ),
  'up' => 
  array (
    0 => 'class.datetime.php',
    1 => 'DateTime',
  ),
  'prev' => 
  array (
    0 => 'datetime.add.php',
    1 => 'DateTime::add',
  ),
  'next' => 
  array (
    0 => 'datetime.createfromformat.php',
    1 => 'DateTime::createFromFormat',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/datetime/datetime/construct.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="datetime.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DateTime::__construct</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">DateTime::__construct</span> &mdash; <span class="dc-title">Returns new DateTime object</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-datetime.construct-description">
  <h3 class="title">Опис</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>DateTime::__construct</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 class="initializer"> = &quot;now&quot;</span></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="class.datetimezone.php" class="type DateTimeZone">DateTimeZone</a></span></span> <code class="parameter">$timezone</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>)</div>

  <p class="para rdfs-comment">
   Like <span class="methodname"><a href="datetimeimmutable.construct.php" class="methodname">DateTimeImmutable::__construct()</a></span> but works with
   <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span>. Consider using the
   <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span> and features instead.
  </p>
  <p class="para">
   Returns a new DateTime object.
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-datetime.construct-parameters">
  <h3 class="title">Параметри</h3>
  <dl>
   
    <dt><code class="parameter">datetime</code></dt>
    <dd>
     <p class="para">Рядок дати/часу. Пояснення коректних форматів надано в <a href="datetime.formats.php" class="link">Формати дати й часу</a>.</p>
     <p class="para">
      Enter <code class="literal">&quot;now&quot;</code> here to obtain the current time when using
      the <code class="parameter">$timezone</code> parameter.
     </p>
    </dd>
   
   
    <dt><code class="parameter">timezone</code></dt>
    <dd>
     <p class="para">
      A <span class="classname"><a href="class.datetimezone.php" class="classname">DateTimeZone</a></span> object representing the
      timezone of <code class="parameter">$datetime</code>.
     </p>
     <p class="para">
      If <code class="parameter">$timezone</code> is omitted or <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>,
      the current timezone will be used.
     </p>
     <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
      <p class="para">
       The <code class="parameter">$timezone</code> parameter
       and the current timezone are ignored when the
       <code class="parameter">$datetime</code> parameter either
       is a UNIX timestamp (e.g. <code class="literal">@946684800</code>)
       or specifies a timezone
       (e.g. <code class="literal">2010-01-28T15:00:00+02:00</code>).
      </p>
     </p></blockquote>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-datetime.construct-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns a new DateTime instance.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-datetime.construct-errors">
  <h3 class="title">Помилки/виключення</h3>
  <p class="para">
    If an invalid Date/Time string is passed,
    <span class="exceptionname"><strong class="exceptionname">DateMalformedStringException</strong></span> is thrown.
    Previous to PHP 8.3, this was <span class="exceptionname"><a href="class.exception.php" class="exceptionname">Exception</a></span>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-datetime.construct-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.3.0</td>
       <td>
        Now throws
        <span class="exceptionname"><strong class="exceptionname">DateMalformedStringException</strong></span> if an
        invalid string is passed, instead of
        <span class="exceptionname"><a href="class.exception.php" class="exceptionname">Exception</a></span>.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-datetime.construct-seealso">
  <h3 class="title">Прогляньте також</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="datetimeimmutable.construct.php" class="methodname" rel="rdfs-seeAlso">DateTimeImmutable::__construct()</a> - Returns new DateTimeImmutable object</span></li>
  </ul>
 </div>


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