Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 4001

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get the local time</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.idate.html">idate</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.microtime.html">microtime</a></div>
 <div class="up"><a href="ref.datetime.html">Date/Time Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.localtime" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">localtime</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">localtime</span> &mdash; <span class="dc-title">Get the local time</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.localtime-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>localtime</strong></span>
    ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$timestamp</code><span class="initializer"> = time()</span></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$is_associative</code><span class="initializer"> = false</span></span>
  ]] )</div>

  <p class="para rdfs-comment">
   The  <span class="function"><strong>localtime()</strong></span> function returns an array
   identical to that of the structure returned by the C function
   call.
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.localtime-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    
    
<dt>
<span class="term"><em><code class="parameter">timestamp</code></em></span><dd>
<p class="para">
The optional <em><code class="parameter">timestamp</code></em> parameter is an
<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> Unix timestamp that defaults to the current
local time if a <em><code class="parameter">timestamp</code></em> is not given. In other
words, it defaults to the value of  <span class="function"><a href="function.time.html" class="function">time()</a></span>.
</p></dd>
</dt>

   
    <dt>

     <span class="term"><em><code class="parameter">is_associative</code></em></span>
     <dd>

      <p class="para">
       If set to <strong><code>FALSE</code></strong> or not supplied then the array is returned as a regular, 
       numerically indexed array.  If the argument is set to <strong><code>TRUE</code></strong> then
        <span class="function"><strong>localtime()</strong></span> returns an associative array containing
       all the different elements of the structure returned by the C
       function call to localtime.  The names of the different keys of
       the associative array are as follows:
      </p>
      <p class="para">
       <ul class="itemizedlist">
        <li class="listitem">
         <span class="simpara">
          &quot;tm_sec&quot; - seconds, <em>0</em> to <em>59</em>
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;tm_min&quot; - minutes, <em>0</em> to <em>59</em>
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;tm_hour&quot; - hours, <em>0</em> to <em>23</em>
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;tm_mday&quot; - day of the month, <em>1</em> to <em>31</em>
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;tm_mon&quot; - month of the year, <em>0</em> (Jan) to <em>11</em> (Dec)
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;tm_year&quot; - years since 1900
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;tm_wday&quot; - day of the week, <em>0</em> (Sun) to <em>6</em> (Sat)
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;tm_yday&quot; - day of the year, <em>0</em> to <em>365</em>
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;tm_isdst&quot; - is daylight savings time in effect? 
         </span>
         <span class="simpara">
          Positive if yes, <em>0</em> if not, negative if unknown.
         </span>
        </li>
       </ul>
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.localtime-errors">
  <h3 class="title">Errors/Exceptions</h3>
   
   <p class="para">
Every call to a date/time function will generate a <strong><code>E_NOTICE</code></strong>
if the time zone is not valid, and/or a <strong><code>E_STRICT</code></strong>
or <strong><code>E_WARNING</code></strong> message
if using the system settings or the <var class="varname"><var class="varname">TZ</var></var> environment
variable. See also  <span class="function"><a href="function.date-default-timezone-set.html" class="function">date_default_timezone_set()</a></span></p>
 
 </div>


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

     </thead>

     <tbody class="tbody">
      
      <tr><td>5.1.0</td><td><p class="para">
Now issues the <strong><code>E_STRICT</code></strong> and <strong><code>E_NOTICE</code></strong>
time zone errors.</p></td></tr>

     
     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.localtime-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2311">
    <p><strong>Example #1  <span class="function"><strong>localtime()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$localtime&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">localtime</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$localtime_assoc&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">localtime</span><span style="color: #007700">(</span><span style="color: #0000BB">time</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$localtime</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$localtime_assoc</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [0] =&gt; 24
    [1] =&gt; 3
    [2] =&gt; 19
    [3] =&gt; 3
    [4] =&gt; 3
    [5] =&gt; 105
    [6] =&gt; 0
    [7] =&gt; 92
    [8] =&gt; 1
)

Array
(
    [tm_sec] =&gt; 24
    [tm_min] =&gt; 3
    [tm_hour] =&gt; 19
    [tm_mday] =&gt; 3
    [tm_mon] =&gt; 3
    [tm_year] =&gt; 105
    [tm_wday] =&gt; 0
    [tm_yday] =&gt; 92
    [tm_isdst] =&gt; 1
)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.localtime-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.getdate.html" class="function" rel="rdfs-seeAlso">getdate()</a> - Get date/time information</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.idate.html">idate</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.microtime.html">microtime</a></div>
 <div class="up"><a href="ref.datetime.html">Date/Time Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>