<!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>Get formatterʼs timezone</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="intldateformatter.getcalendarobject.html">IntlDateFormatter::getCalendarObject</a></div> <div class="next" style="text-align: right; float: right;"><a href="intldateformatter.islenient.html">IntlDateFormatter::isLenient</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.gettimezone" class="refentry"> <div class="refnamediv"> <h1 class="refname">IntlDateFormatter::getTimeZone</h1> <h1 class="refname">datefmt_get_timezone</h1> <p class="verinfo">(PHP 5 >= 5.5.0, PECL intl >= 3.0.0)</p><p class="refpurpose"><span class="refname">IntlDateFormatter::getTimeZone</span> -- <span class="refname">datefmt_get_timezone</span> — <span class="dc-title">Get formatterʼs timezone</span></p> </div> <div class="refsect1 description" id="refsect1-intldateformatter.gettimezone-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.intltimezone.html" class="type IntlTimeZone">IntlTimeZone</a></span> <span class="methodname"><strong>IntlDateFormatter::getTimeZone</strong></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> Procedural style </p> <div class="methodsynopsis dc-description"> <span class="type"><a href="class.intltimezone.html" class="type IntlTimeZone">IntlTimeZone</a></span> <span class="methodname"><strong>datefmt_get_timezone</strong></span> ( <span class="methodparam">void</span> )</div> <p class="para rdfs-comment"> Returns an <a href="class.intltimezone.html" class="classname">IntlTimeZone</a> object representing the timezone that will be used by this object to format dates and times. When formatting <a href="class.intlcalendar.html" class="classname">IntlCalendar</a> and <a href="class.datetime.html" class="classname">DateTime</a> objects with this <a href="class.intldateformatter.html" class="classname">IntlDateFormatter</a>, the timezone used will be the one returned by this method, not the one associated with the objects being formatted. </p> </div> <div class="refsect1 parameters" id="refsect1-intldateformatter.gettimezone-parameters"> <h3 class="title">Parameters</h3> <p class="para">This function has no parameters.</p> </div> <div class="refsect1 returnvalues" id="refsect1-intldateformatter.gettimezone-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The associated <a href="class.intltimezone.html" class="classname">IntlTimeZone</a> object or <strong><code>FALSE</code></strong> on failure. </p> </div> <div class="refsect1 examples" id="refsect1-intldateformatter.gettimezone-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-2648"> <p><strong>Example #1 <span class="function"><strong>IntlDateFormatter::getTimeZone()</strong></span> examples</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br />$madrid </span><span style="color: #007700">= </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: #0000BB">NULL</span><span style="color: #007700">, </span><span style="color: #0000BB">NULL</span><span style="color: #007700">, </span><span style="color: #0000BB">NULL</span><span style="color: #007700">, </span><span style="color: #DD0000">'Europe/Madrid'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$lisbon </span><span style="color: #007700">= </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: #0000BB">NULL</span><span style="color: #007700">, </span><span style="color: #0000BB">NULL</span><span style="color: #007700">, </span><span style="color: #0000BB">NULL</span><span style="color: #007700">, </span><span style="color: #DD0000">'Europe/Lisbon'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$madrid</span><span style="color: #007700">-></span><span style="color: #0000BB">getTimezone</span><span style="color: #007700">());<br />echo </span><span style="color: #0000BB">$madrid</span><span style="color: #007700">-></span><span style="color: #0000BB">getTimezone</span><span style="color: #007700">()-></span><span style="color: #0000BB">getDisplayName</span><span style="color: #007700">(<br /> </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #0000BB">IntlTimeZone</span><span style="color: #007700">::</span><span style="color: #0000BB">DISPLAY_GENERIC_LOCATION</span><span style="color: #007700">, </span><span style="color: #DD0000">"en_US"</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">$lisbon</span><span style="color: #007700">-></span><span style="color: #0000BB">getTimeZone</span><span style="color: #007700">()-></span><span style="color: #0000BB">getId</span><span style="color: #007700">(), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">//The id can also be retrieved with ->getTimezoneId()<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$lisbon</span><span style="color: #007700">-></span><span style="color: #0000BB">getTimeZoneId</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> object(IntlTimeZone)#4 (4) { ["valid"]=> bool(true) ["id"]=> string(13) "Europe/Madrid" ["rawOffset"]=> int(3600000) ["currentOffset"]=> int(7200000) } Spain Time Europe/Lisbon Europe/Lisbon </pre></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-intldateformatter.gettimezone-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="intldateformatter.gettimezoneid.html" class="function" rel="rdfs-seeAlso">IntlDateFormatter::getTimeZoneId()</a> - Get the timezone-id used for the IntlDateFormatter</span></li> <li class="member"> <span class="function"><a href="intldateformatter.settimezone.html" class="function" rel="rdfs-seeAlso">IntlDateFormatter::setTimeZone()</a> - Sets formatterʼs timezone</span></li> <li class="member"><a href="class.intltimezone.html" class="classname">IntlTimeZone</a></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.getcalendarobject.html">IntlDateFormatter::getCalendarObject</a></div> <div class="next" style="text-align: right; float: right;"><a href="intldateformatter.islenient.html">IntlDateFormatter::isLenient</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>