<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'datetime.construct.php',
    1 => 'DateTime::__construct',
    2 => 'Liefert ein neues DateTime-Objekt',
  ),
  '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' => 'de',
    '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">Liefert ein neues DateTime-Objekt</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-datetime.construct-description">
  <h3 class="title">Beschreibung</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">
   Wie <span class="methodname"><a href="datetimeimmutable.construct.php" class="methodname">DateTimeImmutable::__construct()</a></span>, verwendet aber
   <span class="classname"><a href="class.datetime.php" class="classname">DateTime</a></span>. Es sollte in Betracht gezogen werden, die
   Klasse <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span> und deren Features zu
   verwenden.
  </p>
  <p class="para">
   Gibt ein neues DateTime-Objekt zurück.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-datetime.construct-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <dl>
   
    <dt><code class="parameter">datetime</code></dt>
    <dd>
     <p class="para">Ein Datums/Zeit Zeichenkette. 
Gültige Formate werden unter <a href="datetime.formats.php" class="link">Datums- und Zeitformate</a> erläutert.</p>
     <p class="para">
      Wenn der Parameter <code class="parameter">$timezone</code> verwendet wird, kann
      hier mit der Übergabe von <code class="literal">&quot;now&quot;</code> die aktuelle Zeit
      ermittelt werden.
     </p>
    </dd>
   
   
    <dt><code class="parameter">timezone</code></dt>
    <dd>
     <p class="para">
      Ein <span class="classname"><a href="class.datetimezone.php" class="classname">DateTimeZone</a></span>-Objekt, welches die Zeitzone
      von <code class="parameter">$datetime</code> repräsentiert.
     </p>
     <p class="para">
      Wenn <code class="parameter">$timezone</code> nicht übergeben wird oder <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>
      ist, wird die aktuelle Zeitzone verwendet.
     </p>
     <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
      <p class="para">
       Der Parameter <code class="parameter">$timezone</code> und die aktuelle
       Zeitzone werden ignoriert, wenn der Parameter
       <code class="parameter">$datetime</code> entweder ein UNIX-Zeitstempel ist
       (z. B. <code class="literal">@946684800</code>), oder wenn in ihm eine Zeitzone
       spezifiziert wird (z. B. <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">Rückgabewerte</h3>
  <p class="para">
   Gibt eine neue Instanz von DateTime zurück.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-datetime.construct-errors">
  <h3 class="title">Fehler/Exceptions</h3>
  <p class="para">
   Wenn eine ungültige Datum/Uhrzeit-Zeichenkette übergeben wird, wird eine
   <span class="exceptionname"><a href="class.datemalformedstringexception.php" class="exceptionname">DateMalformedStringException</a></span> geworfen. Vor
   PHP 8.3 wird eine <span class="exceptionname"><a href="class.exception.php" class="exceptionname">Exception</a></span> geworfen.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-datetime.construct-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Beschreibung</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.3.0</td>
       <td>
        Wirft nun eine
        <span class="exceptionname"><a href="class.datemalformedstringexception.php" class="exceptionname">DateMalformedStringException</a></span>
        anstelle von <span class="exceptionname"><a href="class.exception.php" class="exceptionname">Exception</a></span>, wenn eine
        ungültige Zeichenkette übergeben wird.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-datetime.construct-seealso">
  <h3 class="title">Siehe auch</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="datetimeimmutable.construct.php" class="methodname" rel="rdfs-seeAlso">DateTimeImmutable::__construct()</a> - Liefert ein neues DateTimeImmutable-Objekt</span></li>
  </ul>
 </div>


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