Sophie

Sophie

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

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 time zone for the DateTime object</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="datetime.settimestamp.html">DateTime::setTimestamp</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="datetime.sub.html">DateTime::sub</a></div>
 <div class="up"><a href="class.datetime.html">DateTime</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="datetime.settimezone" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DateTime::setTimezone</h1>
  <h1 class="refname">date_timezone_set</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0)</p><p class="refpurpose"><span class="refname">DateTime::setTimezone</span> -- <span class="refname">date_timezone_set</span> &mdash; <span class="dc-title">Sets the time zone for the DateTime object</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-datetime.settimezone-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="type"><a href="class.datetime.html" class="type DateTime">DateTime</a></span> <span class="methodname"><strong>DateTime::setTimezone</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.datetimezone.html" class="type DateTimeZone">DateTimeZone</a></span> <code class="parameter">$timezone</code></span>
   )</div>

  <p class="para rdfs-comment">Procedural style</p>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="class.datetime.html" class="type DateTime">DateTime</a></span> <span class="methodname"><a href="function.date-timezone-set.html" class="methodname">date_timezone_set</a></span>
    ( <span class="methodparam"><span class="type"><a href="class.datetime.html" class="type DateTime">DateTime</a></span> <code class="parameter">$object</code></span>
   , <span class="methodparam"><span class="type"><a href="class.datetimezone.html" class="type DateTimeZone">DateTimeZone</a></span> <code class="parameter">$timezone</code></span>
   )</div>

  <p class="para rdfs-comment">
   Sets a new timezone for a <a href="class.datetime.html" class="classname">DateTime</a> <span class="type"><a href="language.types.object.html" class="type object">object</a></span>.
  </p>
 </div>


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

   <dt>
<span class="term"><em><code class="parameter">object</code></em></span>
<dd>
<p class="para">Procedural style only: A <a href="class.datetime.html" class="classname">DateTime</a> object
returned by  <span class="function"><a href="function.date-create.html" class="function">date_create()</a></span>.
The function modifies this object.</p></dd>
</dt>

   <dt>

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

     <p class="para">
      A <a href="class.datetimezone.html" class="classname">DateTimeZone</a> object representing the
      desired time zone.
     </p>
    </dd>

   </dt>

  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-datetime.settimezone-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the <a href="class.datetime.html" class="classname">DateTime</a> object for method chaining or <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-datetime.settimezone-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr><td>5.3.0</td><td>Changed the
return value on success from <strong><code>NULL</code></strong> to <a href="class.datetime.html" class="classname">DateTime</a>.</td></tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-datetime.settimezone-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-2269">
   <p><strong>Example #1  <span class="function"><strong>DateTime::setTimeZone()</strong></span> example</strong></p>
   <div class="example-contents"><p>Object oriented style</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$date&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DateTime</span><span style="color: #007700">(</span><span style="color: #DD0000">'2000-01-01'</span><span style="color: #007700">,&nbsp;new&nbsp;</span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">(</span><span style="color: #DD0000">'Pacific/Nauru'</span><span style="color: #007700">));<br />echo&nbsp;</span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d&nbsp;H:i:sP'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setTimezone</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">DateTimeZone</span><span style="color: #007700">(</span><span style="color: #DD0000">'Pacific/Chatham'</span><span style="color: #007700">));<br />echo&nbsp;</span><span style="color: #0000BB">$date</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(</span><span style="color: #DD0000">'Y-m-d&nbsp;H:i:sP'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>Procedural style</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$date&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">date_create</span><span style="color: #007700">(</span><span style="color: #DD0000">'2000-01-01'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">timezone_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'Pacific/Nauru'</span><span style="color: #007700">));<br />echo&nbsp;</span><span style="color: #0000BB">date_format</span><span style="color: #007700">(</span><span style="color: #0000BB">$date</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Y-m-d&nbsp;H:i:sP'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">date_timezone_set</span><span style="color: #007700">(</span><span style="color: #0000BB">$date</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">timezone_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'Pacific/Chatham'</span><span style="color: #007700">));<br />echo&nbsp;</span><span style="color: #0000BB">date_format</span><span style="color: #007700">(</span><span style="color: #0000BB">$date</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Y-m-d&nbsp;H:i:sP'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>The above examples will output:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
2000-01-01 00:00:00+12:00
2000-01-01 01:45:00+13:45
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-datetime.settimezone-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li class="member"> <span class="function"><a href="datetime.gettimezone.html" class="function" rel="rdfs-seeAlso">DateTime::getTimezone()</a> - Return time zone relative to given DateTime</span></li>
   <li class="member"> <span class="function"><a href="datetimezone.construct.html" class="function" rel="rdfs-seeAlso">DateTimeZone::__construct()</a> - Creates new DateTimeZone object</span></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="datetime.settimestamp.html">DateTime::setTimestamp</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="datetime.sub.html">DateTime::sub</a></div>
 <div class="up"><a href="class.datetime.html">DateTime</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>