@@ -7298,9 +7298,11 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
7298
7298
<listitem>
7299
7299
<para>
7300
7300
For <type>timestamp with time zone</type> values, the
7301
- number of seconds since 1970-01-01 00:00:00 UTC (can be negative);
7301
+ number of seconds since 1970-01-01 00:00:00 UTC (negative for
7302
+ timestamps before that);
7302
7303
for <type>date</type> and <type>timestamp</type> values, the
7303
- number of seconds since 1970-01-01 00:00:00 local time;
7304
+ nominal number of seconds since 1970-01-01 00:00:00,
7305
+ without regard to timezone or daylight-savings rules;
7304
7306
for <type>interval</type> values, the total number
7305
7307
of seconds in the interval
7306
7308
</para>
@@ -7309,20 +7311,28 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
7309
7311
SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40.12-08');
7310
7312
<lineannotation>Result: </lineannotation><computeroutput>982384720.12</computeroutput>
7311
7313
7314
+ SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40.12');
7315
+ <lineannotation>Result: </lineannotation><computeroutput>982355920.12</computeroutput>
7316
+
7312
7317
SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours');
7313
7318
<lineannotation>Result: </lineannotation><computeroutput>442800</computeroutput>
7314
7319
</screen>
7315
7320
7316
7321
<para>
7317
- Here is how you can convert an epoch value back to a time
7318
- stamp :
7322
+ You can convert an epoch value back to a<type>timestamp with time zone</type>
7323
+ with <function>to_timestamp</function> :
7319
7324
</para>
7320
7325
<screen>
7321
- SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 982384720.12 * INTERVAL '1 second';
7326
+ SELECT to_timestamp(982384720.12);
7327
+ <lineannotation>Result: </lineannotation><computeroutput>2001-02-17 04:38:40.12+00</computeroutput>
7322
7328
</screen>
7329
+
7323
7330
<para>
7324
- (The <function>to_timestamp</> function encapsulates the above
7325
- conversion.)
7331
+ Beware that applying <function>to_timestamp</function> to an epoch
7332
+ extracted from a <type>date</type> or <type>timestamp</type> value
7333
+ could produce a misleading result: the result will effectively
7334
+ assume that the original value had been given in UTC, which might
7335
+ not be the case.
7326
7336
</para>
7327
7337
</listitem>
7328
7338
</varlistentry>