<?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.microtime.php',
    1 => 'microtime',
    2 => 'Liefert den aktuellen Unix-Zeitstempel mit Mikrosekunden',
  ),
  'up' => 
  array (
    0 => 'ref.datetime.php',
    1 => 'Datum/Uhrzeit-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.localtime.php',
    1 => 'localtime',
  ),
  'next' => 
  array (
    0 => 'function.mktime.php',
    1 => 'mktime',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/datetime/functions/microtime.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.microtime" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">microtime</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">microtime</span> &mdash; <span class="dc-title">Liefert den aktuellen Unix-Zeitstempel mit Mikrosekunden</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.microtime-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>microtime</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$as_float</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.float.php" class="type float">float</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>microtime()</strong></span> gibt den aktuellen Unix-Zeitstempel mit
   Mikrosekunden zurück. Diese Funktion steht nur auf Systemen zur Verfügung,
   die den Systemaufruf gettimeofday() unterstützen.
  </p>
  <p class="para">
   Für Leistungsfähigkeitsmessungen wird die Verwendung von
   <span class="function"><a href="function.hrtime.php" class="function">hrtime()</a></span> empfohlen.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.microtime-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">as_float</code></dt>
     <dd>
      <p class="para">
       Wenn auf <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> gesetzt, gibt <span class="function"><strong>microtime()</strong></span> einen
       <span class="type"><a href="language.types.float.php" class="link">Float</a></span> anstatt eines <span class="type"><a href="language.types.string.php" class="link">String</a></span>s zurück, wie
       im Abschnitt Rückgabewerte unten genauer erläutert wird.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.microtime-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Standardmäßig gibt <span class="function"><strong>microtime()</strong></span> einen <span class="type"><a href="language.types.string.php" class="link">String</a></span>
   im Format &quot;msec sec&quot; zurück, wobei <code class="literal">sec</code> die Sekunden seit
   Beginn der Unix-Epoche (01. Januar 1970 00:00:00 GMT) sind und
   <code class="literal">msec</code> die Anzahl an Mikrosekunden misst, die seit
   <code class="literal">sec</code> vergangen sind, was als Dezimalzahl mit
   Nachkommastellen ebenso in Sekunden ausgedrückt wird.
  </p>
  <p class="para">
   Wenn <code class="parameter">as_float</code> <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> ist, gibt
   <span class="function"><strong>microtime()</strong></span> einen <span class="type"><a href="language.types.float.php" class="link">Float</a></span> zurück, welcher
   die aktuelle Zeit in Sekunden seit Beginn der Unix-Epoche angibt (die
   Nachkommastellen geben die Mikrosekunden an).
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.microtime-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 Zeitmessung einer Skriptausführung</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$time_start </span><span style="color: #007700">= </span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// Die Skriptverarbeitung fuer einen bestimmten Zeitraum unterbrechen<br /></span><span style="color: #0000BB">usleep</span><span style="color: #007700">(</span><span style="color: #0000BB">10_000</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$time_end </span><span style="color: #007700">= </span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$time </span><span style="color: #007700">= </span><span style="color: #0000BB">$time_end </span><span style="color: #007700">- </span><span style="color: #0000BB">$time_start</span><span style="color: #007700">;<br /><br />echo </span><span style="color: #DD0000">"In </span><span style="color: #0000BB">$time</span><span style="color: #DD0000"> Sekunden nichts getan\n"</span><span style="color: #007700">;</span></span></code></div>
    </div>

   </div>
   <div class="example" id="example-2">
    <p><strong>Beispiel #2 <span class="function"><strong>microtime()</strong></span> und <code class="literal">REQUEST_TIME_FLOAT</code></strong></p>
    <div class="example-contents">
<div class="annotation-non-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// zufällige Pausendauer<br /></span><span style="color: #0000BB">usleep</span><span style="color: #007700">(</span><span style="color: #0000BB">random_int</span><span style="color: #007700">(</span><span style="color: #0000BB">10_000</span><span style="color: #007700">, </span><span style="color: #0000BB">1_000_000</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// REQUEST_TIME_FLOAT ist im superglobalen Array $_SERVER verfügbar.<br />// Es enthält den Zeitstempel des Beginns der Anfrage in Mikrosekunden-Auflösung.<br /></span><span style="color: #0000BB">$time </span><span style="color: #007700">= </span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">) - </span><span style="color: #0000BB">$_SERVER</span><span style="color: #007700">[</span><span style="color: #DD0000">"REQUEST_TIME_FLOAT"</span><span style="color: #007700">];<br /><br />echo </span><span style="color: #DD0000">"Nichts getan in </span><span style="color: #0000BB">$time</span><span style="color: #DD0000"> Sekunden\n"</span><span style="color: #007700">;</span></span></code></div>
    </div>

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


 <div class="refsect1 seealso" id="refsect1-function.microtime-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.time.php" class="function" rel="rdfs-seeAlso">time()</a> - Liefert den aktuellen Unix-Zeitstempel</span></li>
    <li><span class="function"><a href="function.hrtime.php" class="function" rel="rdfs-seeAlso">hrtime()</a> - Get the system's high resolution time</span></li>
   </ul>
  </p>
 </div>


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