Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 3736

php-manual-en-7.2.11-1.mga7.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 date/time information</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.date.html">date</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.gettimeofday.html">gettimeofday</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.getdate" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">getdate</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">getdate</span> &mdash; <span class="dc-title">Get date/time information</span></p>

 </div>

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

  <p class="para rdfs-comment">
   Returns an associative <span class="type"><a href="language.types.array.html" class="type array">array</a></span> containing the date
   information of the <code class="parameter">timestamp</code>, or the current
   local time if no <code class="parameter">timestamp</code> is given.
  </p>
 </div>


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

    
    
<dt>
<code class="parameter">timestamp</code></dt>
<dd>
<p class="para">
The optional <code class="parameter">timestamp</code> 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 <code class="parameter">timestamp</code> 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>

   
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.getdate-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an associative <span class="type"><a href="language.types.array.html" class="type array">array</a></span> of information related to
   the <code class="parameter">timestamp</code>. Elements from the returned 
   associative array are as follows:
  </p>
  <p class="para">
   <table class="doctable table">
    <caption><strong>Key elements of the returned associative array</strong></caption>
    
     <thead>
      <tr>
       <th>Key</th>
       <th>Description</th>
       <th>Example returned values</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td><em>&quot;seconds&quot;</em></td>
       <td>Numeric representation of seconds</td>
       <td><em>0</em> to <em>59</em></td>
      </tr>

      <tr>
       <td><em>&quot;minutes&quot;</em></td>
       <td>Numeric representation of minutes</td>
       <td><em>0</em> to <em>59</em></td>
      </tr>

      <tr>
       <td><em>&quot;hours&quot;</em></td>
       <td>Numeric representation of hours</td>
       <td><em>0</em> to <em>23</em></td>
      </tr>

      <tr>
       <td><em>&quot;mday&quot;</em></td>
       <td>Numeric representation of the day of the month</td>
       <td><em>1</em> to <em>31</em></td>
      </tr>

      <tr>
       <td><em>&quot;wday&quot;</em></td>
       <td>Numeric representation of the day of the week</td>
       <td><em>0</em> (for Sunday) through <em>6</em> (for Saturday)</td>
      </tr>

      <tr>
       <td><em>&quot;mon&quot;</em></td>
       <td>Numeric representation of a month</td>
       <td><em>1</em> through <em>12</em></td>
      </tr>

      <tr>
       <td><em>&quot;year&quot;</em></td>
       <td>A full numeric representation of a year, 4 digits</td>
       <td>Examples: <em>1999</em> or <em>2003</em></td>
      </tr>

      <tr>
       <td><em>&quot;yday&quot;</em></td>
       <td>Numeric representation of the day of the year</td>
       <td><em>0</em> through <em>365</em></td>
      </tr>

      <tr>
       <td><em>&quot;weekday&quot;</em></td>
       <td>A full textual representation of the day of the week</td>
       <td><em>Sunday</em> through <em>Saturday</em></td>
      </tr>

      <tr>
       <td><em>&quot;month&quot;</em></td>
       <td>A full textual representation of a month, such as January or March</td>
       <td><em>January</em> through <em>December</em></td>
      </tr>

      <tr>
       <td><em>0</em></td>
       <td>
        Seconds since the Unix Epoch, similar to the values returned by
        <span class="function"><a href="function.time.html" class="function">time()</a></span> and used by <span class="function"><a href="function.date.html" class="function">date()</a></span>.
       </td>
       <td>
        System Dependent, typically <em>-2147483648</em> through
        <em>2147483647</em>.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.getdate-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2805">
    <p><strong>Example #1 <span class="function"><strong>getdate()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$today&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getdate</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$today</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
(
    [seconds] =&gt; 40
    [minutes] =&gt; 58
    [hours]   =&gt; 21
    [mday]    =&gt; 17
    [wday]    =&gt; 2
    [mon]     =&gt; 6
    [year]    =&gt; 2003
    [yday]    =&gt; 167
    [weekday] =&gt; Tuesday
    [month]   =&gt; June
    [0]       =&gt; 1055901520
)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.getdate-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.date.html" class="function" rel="rdfs-seeAlso">date()</a> - Format a local time/date</span></li>
    <li class="member"><span class="function"><a href="function.idate.html" class="function" rel="rdfs-seeAlso">idate()</a> - Format a local time/date as integer</span></li>
    <li class="member"><span class="function"><a href="function.localtime.html" class="function" rel="rdfs-seeAlso">localtime()</a> - Get the local time</span></li>
    <li class="member"><span class="function"><a href="function.time.html" class="function" rel="rdfs-seeAlso">time()</a> - Return current Unix timestamp</span></li>
    <li class="member"><span class="function"><a href="function.setlocale.html" class="function" rel="rdfs-seeAlso">setlocale()</a> - Set locale 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.date.html">date</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.gettimeofday.html">gettimeofday</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>