@@ -8107,9 +8107,11 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
8107
8107
<listitem>
8108
8108
<para>
8109
8109
For <type>timestamp with time zone</type> values, the
8110
- number of seconds since 1970-01-01 00:00:00 UTC (can be negative);
8110
+ number of seconds since 1970-01-01 00:00:00 UTC (negative for
8111
+ timestamps before that);
8111
8112
for <type>date</type> and <type>timestamp</type> values, the
8112
- number of seconds since 1970-01-01 00:00:00 local time;
8113
+ nominal number of seconds since 1970-01-01 00:00:00,
8114
+ without regard to timezone or daylight-savings rules;
8113
8115
for <type>interval</type> values, the total number
8114
8116
of seconds in the interval
8115
8117
</para>
@@ -8118,18 +8120,29 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
8118
8120
SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40.12-08');
8119
8121
<lineannotation>Result: </lineannotation><computeroutput>982384720.12</computeroutput>
8120
8122
8123
+ SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40.12');
8124
+ <lineannotation>Result: </lineannotation><computeroutput>982355920.12</computeroutput>
8125
+
8121
8126
SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours');
8122
8127
<lineannotation>Result: </lineannotation><computeroutput>442800</computeroutput>
8123
8128
</screen>
8124
8129
8125
8130
<para>
8126
- You can convert an epoch value back to a time stamp
8131
+ You can convert an epoch value back to a <type>timestamp with time zone</type>
8127
8132
with <function>to_timestamp</function>:
8128
8133
</para>
8129
8134
<screen>
8130
8135
SELECT to_timestamp(982384720.12);
8131
8136
<lineannotation>Result: </lineannotation><computeroutput>2001-02-17 04:38:40.12+00</computeroutput>
8132
8137
</screen>
8138
+
8139
+ <para>
8140
+ Beware that applying <function>to_timestamp</function> to an epoch
8141
+ extracted from a <type>date</type> or <type>timestamp</type> value
8142
+ could produce a misleading result: the result will effectively
8143
+ assume that the original value had been given in UTC, which might
8144
+ not be the case.
8145
+ </para>
8133
8146
</listitem>
8134
8147
</varlistentry>
8135
8148
0 commit comments