Sophie

Sophie

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

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>Parse a time/date generated with strftime</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.strftime.html">strftime</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.strtotime.html">strtotime</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.strptime" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">strptime</h1>
    <p class="verinfo">(PHP 5 &gt;= 5.1.0)</p><p class="refpurpose"><span class="refname">strptime</span> &mdash; <span class="dc-title">
     Parse a time/date generated with  <span class="function"><a href="function.strftime.html" class="function">strftime()</a></span>
    </span></p>

   </div>
   <div class="refsect1 description" id="refsect1-function.strptime-description">
    <h3 class="title">Description</h3>
    <div class="methodsynopsis dc-description">
     <span class="type">array</span> <span class="methodname"><strong>strptime</strong></span>
      ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$date</code></span>
     , <span class="methodparam"><span class="type">string</span> <code class="parameter">$format</code></span>
     )</div>

    <p class="para rdfs-comment">
      <span class="function"><strong>strptime()</strong></span> returns an array with the
     <em><code class="parameter">date</code></em> parsed, or <strong><code>FALSE</code></strong> on error.
    </p>
    <p class="para">
     Month and weekday names and other language dependent strings respect the
     current locale set with  <span class="function"><a href="function.setlocale.html" class="function">setlocale()</a></span> (<strong><code>LC_TIME</code></strong>).
    </p>
   </div>


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

     <dt>

      <span class="term"><em><code class="parameter">date</code></em> (<span class="type"><a href="language.types.string.html" class="type string">string</a></span>)</span>
      <dd>

       <p class="para">
        The string to parse (e.g. returned from  <span class="function"><a href="function.strftime.html" class="function">strftime()</a></span>).
       </p>
      </dd>

     </dt>

     <dt>

      <span class="term"><em><code class="parameter">format</code></em> (<span class="type"><a href="language.types.string.html" class="type string">string</a></span>)</span>
      <dd>

       <p class="para">
        The format used in <em><code class="parameter">date</code></em> (e.g. the same as
        used in  <span class="function"><a href="function.strftime.html" class="function">strftime()</a></span>). Note that some of the format
        options available to  <span class="function"><a href="function.strftime.html" class="function">strftime()</a></span> may not have any
        effect within  <span class="function"><strong>strptime()</strong></span>; the exact subset that are
        supported will vary based on the operating system and C library in
        use.
       </p>
       <p class="para">
        For more information about the format options, read the
         <span class="function"><a href="function.strftime.html" class="function">strftime()</a></span> page.
       </p>
      </dd>

     </dt>

    </dl>

   </p>
  </div>


  <div class="refsect1 returnvalues" id="refsect1-function.strptime-returnvalues">
   <h3 class="title">Return Values</h3>
   <p class="para">
    Returns an array or <strong><code>FALSE</code></strong> on failure.
   </p>

    <p class="para">
     <table class="doctable table">
      <caption><strong>The following parameters are returned in the array</strong></caption>
      
       <thead>
        <tr>
         <th>parameters</th>
         <th>Description</th>
        </tr>

       </thead>

       <tbody class="tbody">
        <tr>
         <td><em>&quot;tm_sec&quot;</em></td>
         <td>Seconds after the minute (0-61)</td>
        </tr>

        <tr>
         <td><em>&quot;tm_min&quot;</em></td>
         <td>Minutes after the hour (0-59)</td>
        </tr>

        <tr>
         <td><em>&quot;tm_hour&quot;</em></td>
         <td>Hour since midnight (0-23)</td>
        </tr>

        <tr>
         <td><em>&quot;tm_mday&quot;</em></td>
         <td>Day of the month (1-31)</td>
        </tr>

        <tr>
         <td><em>&quot;tm_mon&quot;</em></td>
         <td>Months since January (0-11)</td>
        </tr>

        <tr>
         <td><em>&quot;tm_year&quot;</em></td>
         <td>Years since 1900</td>
        </tr>

        <tr>
         <td><em>&quot;tm_wday&quot;</em></td>
         <td>Days since Sunday (0-6)</td>
        </tr>

        <tr>
         <td><em>&quot;tm_yday&quot;</em></td>
         <td>Days since January 1 (0-365)</td>
        </tr>

        <tr>
         <td><em>&quot;unparsed&quot;</em></td>
         <td>the <em><code class="parameter">date</code></em> part which was not
          recognized using the specified <em><code class="parameter">format</code></em></td>
        </tr>

       </tbody>
      
     </table>

    </p>

  </div>


  <div class="refsect1 examples" id="refsect1-function.strptime-examples">
   <h3 class="title">Examples</h3>
   <p class="para">
   <div class="example" id="example-2322">
    <p><strong>Example #1  <span class="function"><strong>strptime()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$format&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'%d/%m/%Y&nbsp;%H:%M:%S'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$strf&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">strftime</span><span style="color: #007700">(</span><span style="color: #0000BB">$format</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$strf</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">strptime</span><span style="color: #007700">(</span><span style="color: #0000BB">$strf</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$format</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>
03/10/2004 15:54:19

Array
(
    [tm_sec] =&gt; 19
    [tm_min] =&gt; 54
    [tm_hour] =&gt; 15
    [tm_mday] =&gt; 3
    [tm_mon] =&gt; 9
    [tm_year] =&gt; 104
    [tm_wday] =&gt; 0
    [tm_yday] =&gt; 276
    [unparsed] =&gt;
)
</pre></div>
      </div>
      </div>
     </p>
    </div>


    <div class="refsect1 notes" id="refsect1-function.strptime-notes">
     <h3 class="title">Notes</h3>
     <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">This function is not
implemented on Windows platforms.</span></p></blockquote>
     <blockquote class="note"><p><strong class="note">Note</strong>: 
      <p class="para">
       Internally, this function calls the <em>strptime()</em>
       function provided by the system&#039;s C library. This function can exhibit
       noticeably different behaviour across different operating systems. The
       use of  <span class="function"><a href="function.date-parse-from-format.html" class="function">date_parse_from_format()</a></span>, which does not
       suffer from these issues, is recommended on PHP 5.3.0 and later.
      </p>
     </p></blockquote>
     <blockquote class="note"><p><strong class="note">Note</strong>: 
      <p class="para">
       <em>&quot;tm_sec&quot;</em> includes any leap seconds (currently upto 2
       a year). For more information on leap seconds, see the <a href="http://en.wikipedia.org/wiki/Leap_second" class="link external">&raquo;&nbsp;Wikipedia article
       on leap seconds</a>.
      </p>
     </p></blockquote>
     <blockquote class="note"><p><strong class="note">Note</strong>: 
      <p class="para">
       Prior to PHP 5.2.0, this function could return undefined behaviour. Notably,
       the <em>&quot;tm_sec&quot;</em>, <em>&quot;tm_min&quot;</em> and <em>&quot;tm_hour&quot;</em> 
       entries would return undefined values.
      </p>
     </p></blockquote>
    </div>


    <div class="refsect1 seealso" id="refsect1-function.strptime-seealso">
    <h3 class="title">See Also</h3>
    <p class="para">
     <ul class="simplelist">
      <li class="member"> <span class="function"><a href="function.checkdate.html" class="function" rel="rdfs-seeAlso">checkdate()</a> - Validate a Gregorian date</span></li>
      <li class="member"> <span class="function"><a href="function.strftime.html" class="function" rel="rdfs-seeAlso">strftime()</a> - Format a local time/date according to locale settings</span></li>
      <li class="member"> <span class="function"><a href="function.date-parse-from-format.html" class="function" rel="rdfs-seeAlso">date_parse_from_format()</a> - Get info about given date formatted according to the specified format</span></li>
      <li class="member"> <span class="function"><a href="datetime.createfromformat.html" class="function" rel="rdfs-seeAlso">DateTime::createFromFormat()</a> - Returns new DateTime object formatted according to the specified format</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.strftime.html">strftime</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.strtotime.html">strtotime</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>