mirror of
https://github.com/macintoshplus/doc-en.git
synced 2026-03-24 08:52:18 +01:00
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.
113 lines
3.0 KiB
XML
113 lines
3.0 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="datetime.getoffset" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>DateTimeInterface::getOffset</refname>
|
|
<refname>DateTimeImmutable::getOffset</refname>
|
|
<refname>DateTime::getOffset</refname>
|
|
<refname>date_offset_get</refname>
|
|
<refpurpose>Returns the timezone offset</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<para>&style.oop;</para>
|
|
<methodsynopsis role="DateTimeInterface">
|
|
<modifier>public</modifier> <type>int</type><methodname>DateTimeInterface::getOffset</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<methodsynopsis role="DateTimeImmutable">
|
|
<modifier>public</modifier> <type>int</type><methodname>DateTimeImmutable::getOffset</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<methodsynopsis role="DateTime">
|
|
<modifier>public</modifier> <type>int</type><methodname>DateTime::getOffset</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<para>&style.procedural;</para>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>date_offset_get</methodname>
|
|
<methodparam><type>DateTimeInterface</type><parameter>object</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns the timezone offset.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<variablelist>
|
|
&date.datetime.description;
|
|
</variablelist>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Returns the timezone offset in seconds from UTC on success.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<example>
|
|
<title><function>DateTime::getOffset</function> example</title>
|
|
<para>&style.oop;</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$winter = new DateTimeImmutable('2010-12-21', new DateTimeZone('America/New_York'));
|
|
$summer = new DateTimeImmutable('2008-06-21', new DateTimeZone('America/New_York'));
|
|
|
|
echo $winter->getOffset() . "\n";
|
|
echo $summer->getOffset() . "\n";
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>&style.procedural;</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$winter = date_create('2010-12-21', timezone_open('America/New_York'));
|
|
$summer = date_create('2008-06-21', timezone_open('America/New_York'));
|
|
|
|
echo date_offset_get($winter) . "\n";
|
|
echo date_offset_get($summer) . "\n";
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&examples.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
-18000
|
|
-14400
|
|
]]>
|
|
</screen>
|
|
<para>
|
|
Note: -18000 = -5 hours, -14400 = -4 hours.
|
|
</para>
|
|
</example>
|
|
</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
|
|
-->
|