@@ -7555,9 +7555,11 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
7555
7555
<listitem>
7556
7556
<para>
7557
7557
For <type>timestamp with time zone</type> values, the
7558
- number of seconds since 1970-01-01 00:00:00 UTC (can be negative);
7558
+ number of seconds since 1970-01-01 00:00:00 UTC (negative for
7559
+ timestamps before that);
7559
7560
for <type>date</type> and <type>timestamp</type> values, the
7560
- number of seconds since 1970-01-01 00:00:00 local time;
7561
+ nominal number of seconds since 1970-01-01 00:00:00,
7562
+ without regard to timezone or daylight-savings rules;
7561
7563
for <type>interval</type> values, the total number
7562
7564
of seconds in the interval
7563
7565
</para>
@@ -7566,18 +7568,29 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
7566
7568
SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40.12-08');
7567
7569
<lineannotation>Result: </lineannotation><computeroutput>982384720.12</computeroutput>
7568
7570
7571
+ SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40.12');
7572
+ <lineannotation>Result: </lineannotation><computeroutput>982355920.12</computeroutput>
7573
+
7569
7574
SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours');
7570
7575
<lineannotation>Result: </lineannotation><computeroutput>442800</computeroutput>
7571
7576
</screen>
7572
7577
7573
7578
<para>
7574
- You can convert an epoch value back to a time stamp
7575
- with <function>to_timestamp</>:
7579
+ You can convert an epoch value back to a <type>timestamp with time zone</type>
7580
+ with <function>to_timestamp</function >:
7576
7581
</para>
7577
7582
<screen>
7578
7583
SELECT to_timestamp(982384720.12);
7579
7584
<lineannotation>Result: </lineannotation><computeroutput>2001-02-17 04:38:40.12+00</computeroutput>
7580
7585
</screen>
7586
+
7587
+ <para>
7588
+ Beware that applying <function>to_timestamp</function> to an epoch
7589
+ extracted from a <type>date</type> or <type>timestamp</type> value
7590
+ could produce a misleading result: the result will effectively
7591
+ assume that the original value had been given in UTC, which might
7592
+ not be the case.
7593
+ </para>
7581
7594
</listitem>
7582
7595
</varlistentry>
7583
7596
0 commit comments