Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 3573

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>Format a local time/date as integer</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.gmstrftime.html">gmstrftime</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.localtime.html">localtime</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.idate" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">idate</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">idate</span> &mdash; <span class="dc-title">Format a local time/date as integer</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.idate-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>idate</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$format</code></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 a number formatted according to the given format string using the
   given integer <em><code class="parameter">timestamp</code></em> or the current local time
   if no timestamp is given. In other words, <em><code class="parameter">timestamp</code></em>
   is optional and defaults to the value of  <span class="function"><a href="function.time.html" class="function">time()</a></span>.
  </p>
  <p class="para">
   Unlike the function  <span class="function"><a href="function.date.html" class="function">date()</a></span>,  <span class="function"><strong>idate()</strong></span>
   accepts just one char in the <em><code class="parameter">format</code></em> parameter.
  </p>
 </div>


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

    <dt>

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

      <p class="para">
       <table class="doctable table">
        <caption><strong>The following characters are recognized in the
        <em><code class="parameter">format</code></em> parameter string</strong></caption>
        
         <thead>
          <tr>
           <th><em><code class="parameter">format</code></em> character</th>
           <th>Description</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td><em>B</em></td>
           <td>Swatch Beat/Internet Time</td>
          </tr>

          <tr>
           <td><em>d</em></td>
           <td>Day of the month</td>
          </tr>

          <tr>
           <td><em>h</em></td>
           <td>Hour (12 hour format)</td>
          </tr>

          <tr>
           <td><em>H</em></td>
           <td>Hour (24 hour format)</td>
          </tr>

          <tr>
           <td><em>i</em></td>
           <td>Minutes</td>
          </tr>

          <tr>
           <td><em>I</em> (uppercase i)</td>
           <td>returns <em>1</em> if DST is activated,
            <em>0</em> otherwise</td>
          </tr>

          <tr>
           <td><em>L</em> (uppercase l)</td>
           <td>returns <em>1</em> for leap year,
            <em>0</em> otherwise</td>
          </tr>

          <tr>
           <td><em>m</em></td>
           <td>Month number</td>
          </tr>

          <tr>
           <td><em>s</em></td>
           <td>Seconds</td>
          </tr>

          <tr>
           <td><em>t</em></td>
           <td>Days in current month</td>
          </tr>

          <tr>
           <td><em>U</em></td>
           <td>Seconds since the Unix Epoch - January 1 1970 00:00:00 UTC -
            this is the same as  <span class="function"><a href="function.time.html" class="function">time()</a></span></td>
          </tr>

          <tr>
           <td><em>w</em></td>
           <td>Day of the week (<em>0</em> on Sunday)</td>
          </tr>

          <tr>
           <td><em>W</em></td>
           <td>ISO-8601 week number of year, weeks starting on
            Monday</td>
          </tr>

          <tr>
           <td><em>y</em></td>
           <td>Year (1 or 2 digits - check note below)</td>
          </tr>

          <tr>
           <td><em>Y</em></td>
           <td>Year (4 digits)</td>
          </tr>

          <tr>
           <td><em>z</em></td>
           <td>Day of the year</td>
          </tr>

          <tr>
           <td><em>Z</em></td>
           <td>Timezone offset in seconds</td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>

    </dt>

    
    
<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>

      
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.idate-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>.
  </p>
  <p class="para">
   As  <span class="function"><strong>idate()</strong></span> always returns an <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span> and
   as they can&#039;t start with a &quot;0&quot;,  <span class="function"><strong>idate()</strong></span> may return
   fewer digits than you would expect. See the example below.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.idate-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.idate-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.idate-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2310">
    <p><strong>Example #1  <span class="function"><strong>idate()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$timestamp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">'1st&nbsp;January&nbsp;2004'</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//1072915200<br /><br />//&nbsp;this&nbsp;prints&nbsp;the&nbsp;year&nbsp;in&nbsp;a&nbsp;two&nbsp;digit&nbsp;format<br />//&nbsp;however,&nbsp;as&nbsp;this&nbsp;would&nbsp;start&nbsp;with&nbsp;a&nbsp;"0",&nbsp;it<br />//&nbsp;only&nbsp;prints&nbsp;"4"<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">idate</span><span style="color: #007700">(</span><span style="color: #DD0000">'y'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$timestamp</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

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


 <div class="refsect1 seealso" id="refsect1-function.idate-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.getdate.html" class="function" rel="rdfs-seeAlso">getdate()</a> - Get date/time information</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>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.gmstrftime.html">gmstrftime</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.localtime.html">localtime</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>