downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.gettimeofday.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = 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 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.gettimeofday.php',
   
1 => 'gettimeofday',
  ),
 
'up' =>
  array (
   
0 => 'ref.datetime.php',
   
1 => 'Date/Time Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.getdate.php',
   
1 => 'getdate',
  ),
 
'next' =>
  array (
   
0 => 'function.gmdate.php',
   
1 => 'gmdate',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.gettimeofday" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">gettimeofday</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">gettimeofday</span> &mdash; <span class="dc-title">Get current time</span></p>

 </div>

 <a name="function.gettimeofday.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="language.pseudo-types.php#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><b>gettimeofday</b></span>
    ([ <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$return_float</tt></span>
  ] )</div>

  <p class="para rdfs-comment">
   This is an interface to gettimeofday(2). It returns an
   associative array containing the data returned from the system
   call.
  </p>
 </div>


 <a name="function.gettimeofday.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">return_float</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       When set to <b><tt class="constant">TRUE</tt></b>, a float instead of an array is returned.
      </p>
     </dd>

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


 <a name="function.gettimeofday.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   By default an <a href="language.types.array.php" class="type array">array</a> is returned. If <i><tt class="parameter">return_float</tt></i>

   is set, then a <a href="language.types.float.php" class="type float">float</a> is returned.
  </p>
  <p class="para">
   Array keys:
   </p><ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara">
      &quot;sec&quot; - seconds since the Unix Epoch
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;usec&quot; - microseconds
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;minuteswest&quot; - minutes west of Greenwich
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      &quot;dsttime&quot; - type of dst correction
     </span>
    </li>
   </ul><p>
  </p>
 </div>


 <a name="function.gettimeofday.changelog"></a><div class="refsect1 changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   </p><table class="doctable informaltable">
   
     <thead valign="middle">
      <tr valign="middle">
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody valign="middle" class="tbody">
      <tr valign="middle">
       <td align="left">5.1.0</td>
       <td align="left">
        The <i><tt class="parameter">return_float</tt></i>
 parameter was added.
       </td>
      </tr>

     </tbody>
   
   </table>
<p>
  </p>
 </div>


 <a name="function.gettimeofday.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 <b>gettimeofday()</b> example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">gettimeofday</span><span style="color: #007700">());<br /><br />echo&nbsp;</span><span style="color: #0000BB">gettimeofday</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents para"><p>The above example will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [sec] =&gt; 1073504408
    [usec] =&gt; 238215
    [minuteswest] =&gt; 0
    [dsttime] =&gt; 1
)

1073504408.23910
</pre></div>
    </div>
   </div><p>
  </p>
 </div>

</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites