php-doc-en/reference/datetime/functions/date-default-timezone-get.xml
2010-06-05 10:37:33 +00:00

162 lines
3.7 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.date-default-timezone-get" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>date_default_timezone_get</refname>
<refpurpose>
Gets the default timezone used by all date/time functions in a script
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>date_default_timezone_get</methodname>
<void/>
</methodsynopsis>
<para>
In order of preference, this function returns the default timezone by:
<itemizedlist>
<listitem>
<para>
Reading the timezone set using the
<function>date_default_timezone_set</function> function (if any)
</para>
</listitem>
<listitem>
<para>
Reading the <varname>TZ</varname> environment variable (if non empty) (Prior to PHP 5.3.0)
</para>
</listitem>
<listitem>
<para>
Reading the value of the <link linkend="ini.date.timezone">date.timezone</link> ini option
(if set)
</para>
</listitem>
<listitem>
<para>
Querying the host operating system (if supported and allowed by the OS)
</para>
</listitem>
</itemizedlist>
</para>
<para>
If none of the above succeed, <methodname>date_default_timezone_get</methodname>
will return a default timezone of <literal>UTC</literal>.
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a <type>string</type>.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.3.0</entry>
<entry>
The <literal>TZ</literal> environment variable is no longer used to
guess the timezone.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Getting the default timezone</title>
<programlisting role="php">
<![CDATA[
<?php
date_default_timezone_set('Europe/London');
if (date_default_timezone_get()) {
echo 'date_default_timezone_set: ' . date_default_timezone_get() . '<br />';
}
if (ini_get('date.timezone')) {
echo 'date.timezone: ' . ini_get('date.timezone');
}
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
date_default_timezone_set: Europe/London
date.timezone: Europe/London
]]>
</screen>
</example>
</para>
<para>
<example>
<title>Getting the abbreviation of a timezone</title>
<programlisting role="php">
<![CDATA[
<?php
date_default_timezone_set('America/Los_Angeles');
echo date_default_timezone_get() . ' => ' . date('e') . ' => ' . date('T');
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
America/Los_Angeles => America/Los_Angeles => PST
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>date_default_timezone_set</function></member>
<member><xref linkend="timezones" /></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->