mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
docs: improve AT TIME ZONE description
The previous description was unclear. Also add a third example, change use of time zone acronyms to more verbose descriptions, and add a mention that using 'time' with AT TIME ZONE uses the current time zone rules. Backpatch-through: 9.3
This commit is contained in:
parent
f658235a44
commit
a704f8327f
@ -7889,10 +7889,11 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
|
|||||||
</indexterm>
|
</indexterm>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
The <literal>AT TIME ZONE</literal> construct allows conversions
|
The <literal>AT TIME ZONE</literal> converts time
|
||||||
of time stamps to different time zones. <xref
|
stamp <emphasis>without time zone</emphasis> to/from
|
||||||
linkend="functions-datetime-zoneconvert-table"> shows its
|
time stamp <emphasis>with time zone</emphasis>, and
|
||||||
variants.
|
<emphasis>time</emphasis> values to different time zones. <xref
|
||||||
|
linkend="functions-datetime-zoneconvert-table"> shows its variants.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<table id="functions-datetime-zoneconvert-table">
|
<table id="functions-datetime-zoneconvert-table">
|
||||||
@ -7937,24 +7938,33 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
In these expressions, the desired time zone <replaceable>zone</> can be
|
In these expressions, the desired time zone <replaceable>zone</> can be
|
||||||
specified either as a text string (e.g., <literal>'PST'</literal>)
|
specified either as a text string (e.g., <literal>'America/Los_Angeles'</literal>)
|
||||||
or as an interval (e.g., <literal>INTERVAL '-08:00'</literal>).
|
or as an interval (e.g., <literal>INTERVAL '-08:00'</literal>).
|
||||||
In the text case, a time zone name can be specified in any of the ways
|
In the text case, a time zone name can be specified in any of the ways
|
||||||
described in <xref linkend="datatype-timezones">.
|
described in <xref linkend="datatype-timezones">.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Examples (assuming the local time zone is <literal>PST8PDT</>):
|
Examples (assuming the local time zone is <literal>America/Los_Angeles</literal>):
|
||||||
<screen>
|
<screen>
|
||||||
SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'MST';
|
SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'America/Denver';
|
||||||
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 19:38:40-08</computeroutput>
|
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 19:38:40-08</computeroutput>
|
||||||
|
|
||||||
SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'MST';
|
SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'America/Denver';
|
||||||
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 18:38:40</computeroutput>
|
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 18:38:40</computeroutput>
|
||||||
|
|
||||||
|
SELECT TIMESTAMP '2001-02-16 20:38:40-05' AT TIME ZONE 'Asia/Tokyo' AT TIME ZONE 'America/Chicago';
|
||||||
|
<lineannotation>Result: </lineannotation><computeroutput>2001-02-16 05:38:40</computeroutput>
|
||||||
</screen>
|
</screen>
|
||||||
The first example takes a time stamp without time zone and interprets it as MST time
|
The first example adds a time zone to a value that lacks it, and
|
||||||
(UTC-7), which is then converted to PST (UTC-8) for display. The second example takes
|
displays the value using the current <varname>TimeZone</varname>
|
||||||
a time stamp specified in EST (UTC-5) and converts it to local time in MST (UTC-7).
|
setting. The second example shifts the time stamp with time zone value
|
||||||
|
to the specified time zone, and returns the value without a time zone.
|
||||||
|
This allows storage and display of values different from the current
|
||||||
|
<varname>TimeZone</varname> setting. The third example converts
|
||||||
|
Tokyo time to Chicago time. Converting <emphasis>time</emphasis>
|
||||||
|
values to other time zones uses the currently active time zone rules
|
||||||
|
since no date is supplied.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user