Sophie

Sophie

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

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>Gets the default timezone used by all date/time functions in a script</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.date-date-set.html">date_date_set</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.date-default-timezone-set.html">date_default_timezone_set</a></div>
 <div class="up"><a href="ref.datetime.html">Date/Time Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.date-default-timezone-get" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">date_default_timezone_get</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0)</p><p class="refpurpose"><span class="refname">date_default_timezone_get</span> &mdash; <span class="dc-title">
   Gets the default timezone used by all date/time functions in a script
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.date-default-timezone-get-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>date_default_timezone_get</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   In order of preference, this function returns the default timezone by:
   <ul class="itemizedlist">
    <li class="listitem">
     <p class="para">
      Reading the timezone set using the
       <span class="function"><a href="function.date-default-timezone-set.html" class="function">date_default_timezone_set()</a></span> function (if any)
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      Prior to PHP 5.4.0 <em class="emphasis">only</em>: Reading the <var class="varname"><var class="varname">TZ</var></var>
      environment variable (if non empty)
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      Reading the value of the <a href="datetime.configuration.html#ini.date.timezone" class="link">date.timezone</a> ini option
      (if set)
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      Prior to PHP 5.4.0 <em class="emphasis">only</em>: Querying the host operating system (if supported
      and allowed by the OS). This uses an algorithm
      that has to <em class="emphasis">guess</em> the timezone. This is by no means going to work correctly for 
      every situation. A warning is shown when this stage is reached. Do not rely on it to be guessed
      correctly, and set <a href="datetime.configuration.html#ini.date.timezone" class="link">date.timezone</a> to the correct timezone
      instead.
     </p>
    </li>
   </ul>
  </p>
  <p class="para">
   If none of the above succeed,  <span class="methodname"><strong>date_default_timezone_get()</strong></span>
   will return a default timezone of <em>UTC</em>.
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.date-default-timezone-get-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a <span class="type"><a href="language.types.string.html" class="type string">string</a></span>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.date-default-timezone-get-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.4.0</td>
       <td>
        The <em>TZ</em> environment variable is no longer used to
        guess the timezone.
       </td>
      </tr>

      <tr>
       <td>5.4.0</td>
       <td>
        The timezone is no longer guessed from information available through the
        operating system as the guessed timezone can not be relied on.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.date-default-timezone-get-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-2293">
    <p><strong>Example #1 Getting the default timezone</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />date_default_timezone_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'Europe/London'</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">date_default_timezone_get</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'date_default_timezone_set:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">date_default_timezone_get</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">'&lt;br&nbsp;/&gt;'</span><span style="color: #007700">;<br />}<br /><br />if&nbsp;(</span><span style="color: #0000BB">ini_get</span><span style="color: #007700">(</span><span style="color: #DD0000">'date.timezone'</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'date.timezone:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">ini_get</span><span style="color: #007700">(</span><span style="color: #DD0000">'date.timezone'</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output
something similar to:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
date_default_timezone_set: Europe/London
date.timezone: Europe/London
</pre></div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2294">
    <p><strong>Example #2 Getting the abbreviation of a timezone</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />date_default_timezone_set</span><span style="color: #007700">(</span><span style="color: #DD0000">'America/Los_Angeles'</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">date_default_timezone_get</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">'&nbsp;=&gt;&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'e'</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">'&nbsp;=&gt;&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">date</span><span style="color: #007700">(</span><span style="color: #DD0000">'T'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</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>
America/Los_Angeles =&gt; America/Los_Angeles =&gt; PST
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.date-default-timezone-get-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.date-default-timezone-set.html" class="function" rel="rdfs-seeAlso">date_default_timezone_set()</a> - Sets the default timezone used by all date/time functions in a script</span></li>
    <li class="member"><a href="timezones.html" class="xref">List of Supported Timezones</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="function.date-date-set.html">date_date_set</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.date-default-timezone-set.html">date_default_timezone_set</a></div>
 <div class="up"><a href="ref.datetime.html">Date/Time Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>