Sophie

Sophie

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

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>Formats an object</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="intldateformatter.format.html">IntlDateFormatter::format</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="intldateformatter.getcalendar.html">IntlDateFormatter::getCalendar</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.formatobject" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">IntlDateFormatter::formatObject</h1>
  <h1 class="refname">datefmt_format_object</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.5.0, PECL intl &gt;= 3.0.0)</p><p class="refpurpose"><span class="refname">IntlDateFormatter::formatObject</span> -- <span class="refname">datefmt_format_object</span> &mdash; <span class="dc-title">Formats an object</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-intldateformatter.formatobject-description">
  <h3 class="title">Description</h3>
  <p class="para">
   Object oriented style
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="type">string</span> <span class="methodname"><strong>IntlDateFormatter::formatObject</strong></span>
    ( <span class="methodparam"><span class="type">object</span> <code class="parameter">$object</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">$format</code><span class="initializer"> = NULL</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code><span class="initializer"> = NULL</span></span>
  ]] )</div>

  <p class="para rdfs-comment">
   Procedural style
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span>
   <span class="type">string</span> <span class="methodname"><strong>datefmt_format_object</strong></span>
    ( <span class="methodparam"><span class="type">object</span> <code class="parameter">$object</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">$format</code><span class="initializer"> = NULL</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$locale</code><span class="initializer"> = NULL</span></span>
  ]] )</div>

  
  <p class="para rdfs-comment">
   This function allows formatting an <a href="class.intlcalendar.html" class="classname">IntlCalendar</a> or
   <a href="class.datetime.html" class="classname">DateTime</a> object without first explicitly creating a
   <a href="class.intldateformatter.html" class="classname">IntlDateFormatter</a> object.
  </p>
  <p class="para">
   The temporary <a href="class.intldateformatter.html" class="classname">IntlDateFormatter</a> that will be created
   will take the timezone from the passed in object. The timezone database
   bundled with PHP will not be used – ICU&#039;s will be used instead. The timezone
   identifier used in <a href="class.datetime.html" class="classname">DateTime</a> objects must therefore
   also exist in ICU&#039;s database.
  </p>
  
 </div>

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

   <dt>

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

     <p class="para">
      An object of type <a href="class.intlcalendar.html" class="classname">IntlCalendar</a> or
      <a href="class.datetime.html" class="classname">DateTime</a>. The timezone information in the object
      will be used.
     </p>
    </dd>

   </dt>

   <dt>

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

     <p class="para">
      How to format the date/time. This can either be an <span class="type"><a href="language.types.array.html" class="type array">array</a></span> with
      two elements (first the date style, then the time style, these being one
      of the constants <strong><code>IntlDateFormatter::NONE</code></strong>,
      <strong><code>IntlDateFormatter::SHORT</code></strong>,
      <strong><code>IntlDateFormatter::MEDIUM</code></strong>,
      <strong><code>IntlDateFormatter::LONG</code></strong>,
      <strong><code>IntlDateFormatter::FULL</code></strong>), a <span class="type"><span class="type long">long</span></span> with
      the value of one of these constants (in which case it will be used both
      for the time and the date) or a <span class="type"><a href="language.types.string.html" class="type string">string</a></span> with the format
      described in <a href="http://www.icu-project.org/apiref/icu4c/classSimpleDateFormat.html#details" class="link external">&raquo;&nbsp;the ICU
      documentation</a>. If <strong><code>NULL</code></strong>, the default style will be used.
     </p>
    </dd>

   </dt>

   <dt>

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

     <p class="para">
      The locale to use, or <strong><code>NULL</code></strong> to use the <a href="intl.configuration.html#ini.intl.default-locale" class="link">default one</a>.
     </p>
    </dd>

   </dt>

  </dl>

 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-intldateformatter.formatobject-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   A string with result or <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>

 
 
 <div class="refsect1 examples" id="refsect1-intldateformatter.formatobject-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2630">
    <p><strong>Example #1  <span class="function"><strong>IntlDateFormatter::formatObject()</strong></span> examples</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;default&nbsp;timezone&nbsp;is&nbsp;irrelevant;&nbsp;timezone&nbsp;taken&nbsp;from&nbsp;the&nbsp;object&nbsp;*/<br /></span><span style="color: #0000BB">ini_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'date.timezone'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'UTC'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">/*&nbsp;default&nbsp;locale&nbsp;is&nbsp;taken&nbsp;from&nbsp;this&nbsp;ini&nbsp;setting&nbsp;*/<br /></span><span style="color: #0000BB">ini_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'intl.default_locale'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'fr_FR'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$cal&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">IntlCalendar</span><span style="color: #007700">::</span><span style="color: #0000BB">fromDateTime</span><span style="color: #007700">(</span><span style="color: #DD0000">"2013-06-06&nbsp;17:05:06&nbsp;Europe/Dublin"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"default:\n\t"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">formatObject</span><span style="color: #007700">(</span><span style="color: #0000BB">$cal</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br />echo&nbsp;</span><span style="color: #DD0000">"long&nbsp;\$format&nbsp;(full):\n\t"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">formatObject</span><span style="color: #007700">(</span><span style="color: #0000BB">$cal</span><span style="color: #007700">,&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;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br />echo&nbsp;</span><span style="color: #DD0000">"array&nbsp;\$format&nbsp;(none,&nbsp;full):\n\t"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">formatObject</span><span style="color: #007700">(</span><span style="color: #0000BB">$cal</span><span style="color: #007700">,&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">NONE</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br />echo&nbsp;</span><span style="color: #DD0000">"string&nbsp;\$format&nbsp;(d&nbsp;'of'&nbsp;MMMM&nbsp;y):\n\t"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">formatObject</span><span style="color: #007700">(</span><span style="color: #0000BB">$cal</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"d&nbsp;'of'&nbsp;MMMM&nbsp;y"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'en_US'</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br />echo&nbsp;</span><span style="color: #DD0000">"with&nbsp;DateTime:\n\t"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">formatObject</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new&nbsp;</span><span style="color: #0000BB">DateTime</span><span style="color: #007700">(</span><span style="color: #DD0000">"2013-09-09&nbsp;09:09:09&nbsp;Europe/Madrid"</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'es_ES'</span><span style="color: #007700">),<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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>
default:
    6 juin 2013 17:05:06
long $format (full):
    jeudi 6 juin 2013 17:05:06 heure d’été irlandaise
array $format (none, full):
    17:05:06 heure d’été irlandaise
string $format (d &#039;of&#039; MMMM y):
    6 of June 2013
with DateTime:
    lunes, 9 de septiembre de 2013 09:09:09 Hora de verano de Europa central

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

 
</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="intldateformatter.format.html">IntlDateFormatter::format</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="intldateformatter.getcalendar.html">IntlDateFormatter::getCalendar</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>