Files
doc-en/reference/datetime/datetimezone/getoffset.xml
Christoph M. Becker e057f1f552 Remove superfluous changelog entries
Actually, most (or even all) datetime functions returned false prior to
PHP 8.0.0, where they now throw an error.  Besides ZPP failures which
we certainly do not want to document explicitly, that also happened in
case the objects have not been properly initialized, which is so close
to ZPP failures, that we don't want to document that either.

Co-authored-by: Alexander Menshchikov <amenshchikov@gmail.com>

Closes GH-1358.
2022-12-27 16:54:37 +01:00

106 lines
3.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="datetimezone.getoffset" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>DateTimeZone::getOffset</refname>
<refname>timezone_offset_get</refname>
<refpurpose>Returns the timezone offset from GMT</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<para>&style.oop;</para>
<methodsynopsis role="DateTimeZone">
<modifier>public</modifier> <type>int</type><methodname>DateTimeZone::getOffset</methodname>
<methodparam><type>DateTimeInterface</type><parameter>datetime</parameter></methodparam>
</methodsynopsis>
<para>&style.procedural;</para>
<methodsynopsis>
<type>int</type><methodname>timezone_offset_get</methodname>
<methodparam><type>DateTimeZone</type><parameter>object</parameter></methodparam>
<methodparam><type>DateTimeInterface</type><parameter>datetime</parameter></methodparam>
</methodsynopsis>
<para>
This function returns the offset to GMT for the date/time specified in the
<parameter>datetime</parameter> parameter. The GMT offset is calculated
with the timezone information contained in the DateTimeZone object being used.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
&date.datetimezone.description;
<varlistentry>
<term><parameter>datetime</parameter></term>
<listitem>
<para>
DateTime that contains the date/time to compute the offset from.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns time zone offset in seconds.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>DateTimeZone::getOffset</function> examples</title>
<programlisting role="php">
<![CDATA[
<?php
// Create two timezone objects, one for Taipei (Taiwan) and one for
// Tokyo (Japan)
$dateTimeZoneTaipei = new DateTimeZone("Asia/Taipei");
$dateTimeZoneJapan = new DateTimeZone("Asia/Tokyo");
// Create two DateTime objects that will contain the same Unix timestamp, but
// have different timezones attached to them.
$dateTimeTaipei = new DateTime("now", $dateTimeZoneTaipei);
$dateTimeJapan = new DateTime("now", $dateTimeZoneJapan);
// Calculate the GMT offset for the date/time contained in the $dateTimeTaipei
// object, but using the timezone rules as defined for Tokyo
// ($dateTimeZoneJapan).
$timeOffset = $dateTimeZoneJapan->getOffset($dateTimeTaipei);
// Should show int(32400) (for dates after Sat Sep 8 01:00:00 1951 JST).
var_dump($timeOffset);
?>
]]>
</programlisting>
</example>
</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
-->