<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.date.php',
    1 => 'date',
    2 => 'Formatiert einen Unix-Zeitstempel',
  ),
  'up' => 
  array (
    0 => 'ref.datetime.php',
    1 => 'Datum/Uhrzeit-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.checkdate.php',
    1 => 'checkdate',
  ),
  'next' => 
  array (
    0 => 'function.date-add.php',
    1 => 'date_add',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/datetime/functions/date.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.date" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">date</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">date</span> &mdash; <span class="dc-title">Formatiert einen Unix-Zeitstempel</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.date-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>date</strong></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="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">$timestamp</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   Gibt einen formatierten String anhand eines vorzugebenden Musters zurück.
   Dabei wird entweder der angegebene Unix-Zeitstempel
   <code class="parameter">timestamp</code> verwendet oder die gegenwärtige Zeit, wenn
   kein Zeitstempel angegegeben wird. Mit anderen Worten ausgedrückt: Der
   Parameter <code class="parameter">timestamp</code> ist optional und wird mit dem
   Wert der Funktion <span class="function"><a href="function.time.php" class="function">time()</a></span> vorbelegt.
  </p>
  <div class="warning"><strong class="warning">Warnung</strong>
   <p class="para">
    Unix-Zeitstempel berücksichtigen keine Zeitzonen. Mit der Klasse
    <span class="classname"><a href="class.datetimeimmutable.php" class="classname">DateTimeImmutable</a></span> und ihrer Formatierungsmethode
    <span class="methodname"><a href="datetime.format.php" class="methodname">DateTimeInterface::format()</a></span> können Datums- und
    Zeitangaben mit einer angehängten Zeitzone formatiert werden.
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.date-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <dl>
   
    <dt><code class="parameter">format</code></dt>
    <dd>
     <p class="para">
      Von <span class="methodname"><a href="datetime.format.php" class="methodname">DateTimeInterface::format()</a></span> akzeptiertes Format.
     </p>
     <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
      <span class="simpara">
       Die Funktion <span class="function"><strong>date()</strong></span> gibt immer
       <code class="literal">000000</code> als Mikrosekunden aus, weil sie einen
       Parameter vom Typ <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> benötigt, während
       <span class="methodname"><a href="datetime.format.php" class="methodname">DateTimeInterface::format()</a></span> Mikrosekunden
       unterstützt, wenn ein Objekt vom Typ
       <span class="classname"><a href="class.datetimeinterface.php" class="classname">DateTimeInterface</a></span> mit Mikrosekunden erstellt
       wurde.
      </span>
     </p></blockquote>
    </dd>
   

   
<dt><code class="parameter">timestamp</code></dt><dd><p class="para">
Der optionale Parameter <code class="parameter">timestamp</code> ist ein Unix-Zeitstempel
vom Typ <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>. Falls <code class="parameter">timestamp</code> nicht übergeben
wird oder <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> ist, wird die aktuelle lokale Zeit als Standardwert verwendet.
Er entspricht dann also dem Ergebnis der Funktion <span class="function"><a href="function.time.php" class="function">time()</a></span>.
</p></dd>

  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.date-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt eine formatierte Datums-Zeichenkette zurück.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.date-errors">
  <h3 class="title">Fehler/Exceptions</h3>

  <p class="para">
Wenn die Zeitzone ungültig ist, wird bei jedem Aufruf einer Datums/Zeit-Funktion
ein Fehler der Stufe <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> erzeugt. Siehe auch
<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.date-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.0.0</td>
       <td>
        <code class="parameter">timestamp</code> ist jetzt nullbar.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.date-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>date()</strong></span>-Beispiele</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Die Standard-Zeitzone setzen, die verwendet werden soll.<br /></span><span style="color: #0000BB">date_default_timezone_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'UTC'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Gibt etwas aus wie: Monday<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"l"</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Gibt etwas aus wie: Monday 8th of August 2005 03:12:46 PM<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'l jS \of F Y h:i:s A'</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Gibt aus: July 1, 2000 is on a Saturday<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">"July 1, 2000 is on a " </span><span style="color: #007700">. </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"l"</span><span style="color: #007700">, </span><span style="color: #0000BB">mktime</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">7</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">2000</span><span style="color: #007700">)) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* Verwenden von Konstanten im Format-Parameter */<br />// Gibt etwas aus wie: Wed, 25 Sep 2013 15:28:57 -0700<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #0000BB">DATE_RFC2822</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Gibt etwas aus wie: 2000-07-01T00:00:00+00:00<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #0000BB">DATE_ATOM</span><span style="color: #007700">, </span><span style="color: #0000BB">mktime</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">7</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">2000</span><span style="color: #007700">));</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   Um zu verhindern, dass ein erkanntes Zeichen im Formatstring ersetzt wird,
   sollte dieses Zeichen mit einem vorangestellten Backslash maskiert werden.
   Ist das Zeichen mit dem Backslash bereits eine spezielle Zeichenfolge, muss
   dieser Backslash ebenso maskiert werden.
   <div class="example" id="example-2">
    <p><strong>Beispiel #2 Maskieren von Zeichen in <span class="function"><strong>date()</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 /></span><span style="color: #FF8000">// Gibt etwas ähnliches aus wie: Wednesday the 15th<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'l \t\h\e jS'</span><span style="color: #007700">);</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   Es folgen einige Beispiele zur <span class="function"><strong>date()</strong></span>-Formatierung. Es
   ist zu beachten, dass alle anderen Zeichen maskiert werden sollten, da alle
   Zeichen, die im Augenblick eine spezielle Bedeutung haben, unerwünschte
   Resultate liefern. Bei allen weiteren Zeichen kann es durchaus möglich sein,
   dass diesen in zukünftigen PHP-Versionen eine Bedeutung zukommt.
   Beim Maskieren sollte darauf geachtet werden, einfache Anführungszeichen zu
   benutzen, damit Zeichenfolgen wie zum Beispiel \n zu keinem
   Zeilenumbruch führen.
   <div class="example" id="example-3">
    <p><strong>Beispiel #3 <span class="function"><strong>date()</strong></span>-Formatierungen</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Angenommen, heute ist der 10. März 2001, 17:16:18 Uhr und wir<br />// befinden uns in der Zeitzone Mountain Standard Time (MST)<br /><br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"F j, Y, g:i a"</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;                 </span><span style="color: #FF8000">// March 10, 2001, 5:16 pm<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"m.d.y"</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;                         </span><span style="color: #FF8000">// 03.10.01<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"j, n, Y"</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;                       </span><span style="color: #FF8000">// 10, 3, 2001<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"Ymd"</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;                           </span><span style="color: #FF8000">// 20010310<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'h-i-s, j-m-y, it is w Day'</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;     </span><span style="color: #FF8000">// 05-16-18, 10-03-01, 1631 1618 6 Satpm01<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'\i\t \i\s \t\h\e jS \d\a\y.'</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;   </span><span style="color: #FF8000">// it is the 10th day.<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"D M j G:i:s T Y"</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;               </span><span style="color: #FF8000">// Sat Mar 10 17:16:18 MST 2001<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'H:m:s \m \i\s\ \m\o\n\t\h'</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;     </span><span style="color: #FF8000">// 17:03:18 m is month<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"H:i:s"</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;                         </span><span style="color: #FF8000">// 17:16:18<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">"Y-m-d H:i:s"</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;                   </span><span style="color: #FF8000">// 2001-03-10 17:16:18 (the MySQL DATETIME format)</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   Um Datumsangaben in anderen Sprachen auszugeben, kann
   <span class="methodname"><a href="intldateformatter.format.php" class="methodname">IntlDateFormatter::format()</a></span> statt
   <span class="function"><strong>date()</strong></span> verwendet werden.
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.date-notes">
  <h3 class="title">Anmerkungen</h3>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    Um einen Zeitstempel aus einer Textrepräsentation eines Datums zu
    erzeugen, kann die Funktion <span class="function"><a href="function.strtotime.php" class="function">strtotime()</a></span> verwendet
    werden. Einige Datenbanken haben außerdem Funktionen, mit denen ihre
    Datumsformate in Zeitstempel konvertiert werden können (wie z. B. die
    Funktion <a href="http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html" class="link external">&raquo;&nbsp;UNIX_TIMESTAMP</a>
    von MySQL).
   </p>
  </p></blockquote>
  <div class="tip"><strong class="tip">Tipp</strong>
   <p class="para">
    Der Zeitstempel des Verarbeitungsbeginns der HTTP-Anfrage wird in
    <var class="varname"><a href="reserved.variables.server.php" class="classname">$_SERVER['REQUEST_TIME']</a></var> bereitgestellt.
   </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.date-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <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>
    <li><span class="methodname"><a href="datetime.format.php" class="methodname" rel="rdfs-seeAlso">DateTimeInterface::format()</a> - Liefert das Datum formatiert gem&auml;&szlig; dem angegebenen Format</span></li>
    <li><span class="function"><a href="function.gmdate.php" class="function" rel="rdfs-seeAlso">gmdate()</a> - Formatiert eine GMT/UTC Zeit-/Datumsangabe</span></li>
    <li><span class="function"><a href="function.idate.php" class="function" rel="rdfs-seeAlso">idate()</a> - Formatiert einen Teil der lokalen Zeit/des lokalen Datums als Integer</span></li>
    <li><span class="function"><a href="function.getdate.php" class="function" rel="rdfs-seeAlso">getdate()</a> - Liefert Datums- und Zeitinformationen</span></li>
    <li><span class="function"><a href="function.getlastmod.php" class="function" rel="rdfs-seeAlso">getlastmod()</a> - Liefert die Uhrzeit der letzten &Auml;nderung eines Skripts</span></li>
    <li><span class="function"><a href="function.mktime.php" class="function" rel="rdfs-seeAlso">mktime()</a> - Liefert den Unix-Zeitstempel f&uuml;r ein Datum</span></li>
    <li><span class="methodname"><a href="intldateformatter.format.php" class="methodname" rel="rdfs-seeAlso">IntlDateFormatter::format()</a> - Format the date/time value as a string</span></li>
    <li><span class="function"><a href="function.time.php" class="function" rel="rdfs-seeAlso">time()</a> - Liefert den aktuellen Unix-Zeitstempel</span></li>
    <li><a href="class.datetimeinterface.php#datetimeinterface.constants.types" class="link">Vordefinierte DateTime-Konstanten</a></li>
   </ul>
  </p>
 </div>


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