Sophie

Sophie

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

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>Sets the calendar type used by the formatter</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="intldateformatter.parse.html">IntlDateFormatter::parse</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="intldateformatter.setlenient.html">IntlDateFormatter::setLenient</a></div>
 <div class="up"><a href="class.intldateformatter.html">IntlDateFormatter</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="intldateformatter.setcalendar" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">IntlDateFormatter::setCalendar</h1>
  <h1 class="refname">datefmt_set_calendar</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PECL intl &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">IntlDateFormatter::setCalendar</span> -- <span class="refname">datefmt_set_calendar</span> &mdash; <span class="dc-title">Sets the calendar type used by the formatter</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-intldateformatter.setcalendar-description">
  <h3 class="title">Description</h3>
  <p class="para">
   Object oriented style
  </p>
   <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>IntlDateFormatter::setCalendar</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$which</code></span>
    )</div>

  <p class="para rdfs-comment">
   Procedural style
  </p>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><strong>datefmt_set_calendar</strong></span>
   ( <span class="methodparam"><span class="type"><a href="class.intldateformatter.html" class="type IntlDateFormatter">IntlDateFormatter</a></span> <code class="parameter">$fmt</code></span>
  , <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$which</code></span>
   )</div>

  <p class="para rdfs-comment">
   Sets the calendar or calendar type used by the formatter.
  </p> 
  </div>


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

    <dt>

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

      <p class="para">
       The formatter resource.
      </p>
     </dd>

    </dt>

    <dt>

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

      <p class="para">
       This can either be: the <a href="class.intldateformatter.html#intl.intldateformatter-constants.calendartypes" class="link">calendar
       type</a> to use (default is
       <strong><code>IntlDateFormatter::GREGORIAN</code></strong>, which is also used if
       <strong><code>NULL</code></strong> is specified) or an
       <a href="class.intlcalendar.html" class="classname">IntlCalendar</a> object.
     </p>
     <p class="para">
      Any <a href="class.intlcalendar.html" class="classname">IntlCalendar</a> object passed in will be cloned;
      no modifications will be made to the argument object.
     </p>
     <p class="para">
      The timezone of the formatter will only be kept if an
      <a href="class.intlcalendar.html" class="classname">IntlCalendar</a> object is not passed, otherwise the
      new timezone will be that of the passed object.
     </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>

   
 
 <div class="refsect1 returnvalues" id="refsect1-intldateformatter.setcalendar-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> on success or <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>

 
 <div class="refsect1 changelog" id="refsect1-intldateformatter.setcalendar-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.5.0/PECL 3.0.0</td>
       <td>
        It became possible to pass an <a href="class.intlcalendar.html" class="classname">IntlCalendar</a>
        object.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-intldateformatter.setcalendar-examples">
  <h3 class="title">Examples</h3>
   <div class="example" id="example-2655">
    <p><strong>Example #1  <span class="function"><strong>datefmt_set_calendar()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$fmt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">datefmt_create</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'en_US'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'America/Los_Angeles'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">GREGORIAN<br /></span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">'calendar&nbsp;of&nbsp;the&nbsp;formatter&nbsp;is&nbsp;:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">datefmt_get_calendar</span><span style="color: #007700">(</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">datefmt_set_calendar</span><span style="color: #007700">(</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">TRADITIONAL</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">'Now&nbsp;calendar&nbsp;of&nbsp;the&nbsp;formatter&nbsp;is&nbsp;:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">datefmt_get_calendar</span><span style="color: #007700">(</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
   <div class="example" id="example-2656">
    <p><strong>Example #2 OO example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$fmt&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'en_US'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'America/Los_Angeles'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">GREGORIAN&nbsp;&nbsp;<br /></span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">'calendar&nbsp;of&nbsp;the&nbsp;formatter&nbsp;is&nbsp;:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getCalendar</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setCalendar</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">TRADITIONAL</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">'Now&nbsp;calendar&nbsp;of&nbsp;the&nbsp;formatter&nbsp;is&nbsp;:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getCalendar</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
   <p class="para">The above example will output:</p>
   <div class="example-contents screen">
    <div class="cdata"><pre>
calendar of the formatter is : 1
Now calendar of the formatter is : 0
</pre></div>
   </div>

  <div class="example" id="example-2657">
  <p><strong>Example #3 Example with <a href="class.intlcalendar.html" class="classname">IntlCalendar</a> argument</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$time&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"2013-03-03&nbsp;00:00:00&nbsp;UTC"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$formatter&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">create</span><span style="color: #007700">(</span><span style="color: #DD0000">"en_US"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Europe/Amsterdam"</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #DD0000">"before:&nbsp;"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$formatter</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #0000BB">$time</span><span style="color: #007700">),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/*&nbsp;note&nbsp;that&nbsp;the&nbsp;calendar's&nbsp;locale&nbsp;is&nbsp;not&nbsp;used!&nbsp;*/<br /></span><span style="color: #0000BB">$formatter</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setCalendar</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlCalendar</span><span style="color: #007700">::</span><span style="color: #0000BB">createInstance</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"America/New_York"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"pt_PT@calendar=islamic"</span><span style="color: #007700">));<br /><br />echo&nbsp;</span><span style="color: #DD0000">"after:&nbsp;&nbsp;"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$formatter</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #0000BB">$time</span><span style="color: #007700">),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>The above example will output:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
before: Sunday, March 3, 2013 at 1:00:00 AM Central European Standard Time
after:  Saturday, RabiÊ» II 20, 1434 at 7:00:00 PM Eastern Standard Time

</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-intldateformatter.setcalendar-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
    <ul class="simplelist">
    <li class="member"> <span class="function"><a href="intldateformatter.getcalendar.html" class="function" rel="rdfs-seeAlso">datefmt_get_calendar()</a> - Get the calendar type used for the IntlDateFormatter</span></li>
    <li class="member"> <span class="function"><a href="intldateformatter.getcalendarobject.html" class="function" rel="rdfs-seeAlso">datefmt_get_calendar_object()</a> - Get copy of formatterʼs calendar object</span></li>
    <li class="member"> <span class="function"><a href="intldateformatter.create.html" class="function" rel="rdfs-seeAlso">datefmt_create()</a> - Create a date formatter</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="intldateformatter.parse.html">IntlDateFormatter::parse</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="intldateformatter.setlenient.html">IntlDateFormatter::setLenient</a></div>
 <div class="up"><a href="class.intldateformatter.html">IntlDateFormatter</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>