<!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>Set the timezone used by this calendar</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="intlcalendar.settime.html">IntlCalendar::setTime</a></div> <div class="next" style="text-align: right; float: right;"><a href="intlcalendar.todatetime.html">IntlCalendar::toDateTime</a></div> <div class="up"><a href="class.intlcalendar.html">IntlCalendar</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="intlcalendar.settimezone" class="refentry"> <div class="refnamediv"> <h1 class="refname">IntlCalendar::setTimeZone</h1> <p class="verinfo">(PHP 5.5.0, PECL >= 3.0.0a1)</p><p class="refpurpose"><span class="refname">IntlCalendar::setTimeZone</span> — <span class="dc-title">Set the timezone used by this calendar</span></p> </div> <div class="refsect1 description" id="refsect1-intlcalendar.settimezone-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>IntlCalendar::setTimeZone</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">$timeZone</code></span> )</div> <p class="para rdfs-comment"> Defines a new timezone for this calendar. The time represented by the object is preserved to the detriment of the field values. </p> </div> <div class="refsect1 parameters" id="refsect1-intlcalendar.settimezone-parameters"> <h3 class="title">Parameters</h3> <dl> <dt> <span class="term"><em><code class="parameter">timeZone</code></em></span> <dd> <p class="para"> The new timezone to be used by this calendar. It can be specified in the following ways: <ul class="itemizedlist"> <li class="listitem"> <p class="para"> <strong><code>NULL</code></strong>, in which case the default timezone will be used, as specified in the ini setting <a href="datetime.configuration.html#ini.date.timezone" class="link">date.timezone</a> or through the function <span class="function"><a href="function.date-default-timezone-set.html" class="function">date_default_timezone_set()</a></span> and as returned by <span class="function"><a href="function.date-default-timezone-get.html" class="function">date_default_timezone_get()</a></span>. </p> </li> <li class="listitem"> <p class="para"> An <a href="class.intltimezone.html" class="classname">IntlTimeZone</a>, which will be used directly. </p> </li> <li class="listitem"> <p class="para"> A <a href="class.datetimezone.html" class="classname">DateTimeZone</a>. Its identifier will be extracted and an ICU timezone object will be created; the timezone will be backed by ICUʼs database, not PHPʼs. </p> </li> <li class="listitem"> <p class="para"> A <span class="type"><a href="language.types.string.html" class="type string">string</a></span>, which should be a valid ICU timezone identifier. See <span class="function"><strong>IntlTimeZone::createTimeZoneIDEnumeration()</strong></span>. Raw offsets such as <em>"GMT+08:30"</em> are also accepted. </p> </li> </ul> </p> </dd> </dt> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-intlcalendar.settimezone-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> on success and <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 examples" id="refsect1-intlcalendar.settimezone-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-2623"> <p><strong>Example #1 <span class="function"><strong>IntlCalendar::setTimeZone()</strong></span></strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />ini_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'date.timezone'</span><span style="color: #007700">, </span><span style="color: #DD0000">'Europe/Lisbon'</span><span style="color: #007700">);<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">, </span><span style="color: #DD0000">'es_ES'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$cal </span><span style="color: #007700">= new </span><span style="color: #0000BB">IntlGregorianCalendar</span><span style="color: #007700">(</span><span style="color: #0000BB">2013</span><span style="color: #007700">, </span><span style="color: #0000BB">5 </span><span style="color: #FF8000">/* May */</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">12</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br />echo </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">, </span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">"(instant </span><span style="color: #007700">{</span><span style="color: #0000BB">$cal</span><span style="color: #007700">-></span><span style="color: #0000BB">getTime</span><span style="color: #007700">()}</span><span style="color: #DD0000">)\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$cal</span><span style="color: #007700">-></span><span style="color: #0000BB">setTimeZone</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">getGMT</span><span style="color: #007700">());<br />echo </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">, </span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">"(instant </span><span style="color: #007700">{</span><span style="color: #0000BB">$cal</span><span style="color: #007700">-></span><span style="color: #0000BB">getTime</span><span style="color: #007700">()}</span><span style="color: #DD0000">)\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$cal</span><span style="color: #007700">-></span><span style="color: #0000BB">setTimeZone</span><span style="color: #007700">(</span><span style="color: #DD0000">'GMT+03:33'</span><span style="color: #007700">);<br />echo </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">, </span><span style="color: #0000BB">IntlDateFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">FULL</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">"(instant </span><span style="color: #007700">{</span><span style="color: #0000BB">$cal</span><span style="color: #007700">-></span><span style="color: #0000BB">getTime</span><span style="color: #007700">()}</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> sábado, 1 de junio de 2013 12:00:00 Hora de verano de Europa occidental (instant 1370084400000) sábado, 1 de junio de 2013 11:00:00 GMT (instant 1370084400000) sábado, 1 de junio de 2013 14:33:00 GMT+03:33 (instant 1370084400000) </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="intlcalendar.settime.html">IntlCalendar::setTime</a></div> <div class="next" style="text-align: right; float: right;"><a href="intlcalendar.todatetime.html">IntlCalendar::toDateTime</a></div> <div class="up"><a href="class.intlcalendar.html">IntlCalendar</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>