@@ -7748,9 +7748,11 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
7748
7748
<listitem>
7749
7749
<para>
7750
7750
For <type>timestamp with time zone</type> values, the
7751
- number of seconds since 1970-01-01 00:00:00 UTC (can be negative);
7751
+ number of seconds since 1970-01-01 00:00:00 UTC (negative for
7752
+ timestamps before that);
7752
7753
for <type>date</type> and <type>timestamp</type> values, the
7753
- number of seconds since 1970-01-01 00:00:00 local time;
7754
+ nominal number of seconds since 1970-01-01 00:00:00,
7755
+ without regard to timezone or daylight-savings rules;
7754
7756
for <type>interval</type> values, the total number
7755
7757
of seconds in the interval
7756
7758
</para>
@@ -7759,18 +7761,29 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
7759
7761
SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40.12-08');
7760
7762
<lineannotation>Result: </lineannotation><computeroutput>982384720.12</computeroutput>
7761
7763
7764
+ SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40.12');
7765
+ <lineannotation>Result: </lineannotation><computeroutput>982355920.12</computeroutput>
7766
+
7762
7767
SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours');
7763
7768
<lineannotation>Result: </lineannotation><computeroutput>442800</computeroutput>
7764
7769
</screen>
7765
7770
7766
7771
<para>
7767
- You can convert an epoch value back to a time stamp
7772
+ You can convert an epoch value back to a <type>timestamp with time zone</type>
7768
7773
with <function>to_timestamp</function>:
7769
7774
</para>
7770
7775
<screen>
7771
7776
SELECT to_timestamp(982384720.12);
7772
7777
<lineannotation>Result: </lineannotation><computeroutput>2001-02-17 04:38:40.12+00</computeroutput>
7773
7778
</screen>
7779
+
7780
+ <para>
7781
+ Beware that applying <function>to_timestamp</function> to an epoch
7782
+ extracted from a <type>date</type> or <type>timestamp</type> value
7783
+ could produce a misleading result: the result will effectively
7784
+ assume that the original value had been given in UTC, which might
7785
+ not be the case.
7786
+ </para>
7774
7787
</listitem>
7775
7788
</varlistentry>
7776
7789
0 commit comments