@@ -9354,9 +9354,11 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
9354
9354
<listitem>
9355
9355
<para>
9356
9356
For <type>timestamp with time zone</type> values, the
9357
- number of seconds since 1970-01-01 00:00:00 UTC (can be negative);
9357
+ number of seconds since 1970-01-01 00:00:00 UTC (negative for
9358
+ timestamps before that);
9358
9359
for <type>date</type> and <type>timestamp</type> values, the
9359
- number of seconds since 1970-01-01 00:00:00 local time;
9360
+ nominal number of seconds since 1970-01-01 00:00:00,
9361
+ without regard to timezone or daylight-savings rules;
9360
9362
for <type>interval</type> values, the total number
9361
9363
of seconds in the interval
9362
9364
</para>
@@ -9365,18 +9367,29 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40');
9365
9367
SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40.12-08');
9366
9368
<lineannotation>Result: </lineannotation><computeroutput>982384720.12</computeroutput>
9367
9369
9370
+ SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40.12');
9371
+ <lineannotation>Result: </lineannotation><computeroutput>982355920.12</computeroutput>
9372
+
9368
9373
SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours');
9369
9374
<lineannotation>Result: </lineannotation><computeroutput>442800</computeroutput>
9370
9375
</screen>
9371
9376
9372
9377
<para>
9373
- You can convert an epoch value back to a time stamp
9378
+ You can convert an epoch value back to a <type>timestamp with time zone</type>
9374
9379
with <function>to_timestamp</function>:
9375
9380
</para>
9376
9381
<screen>
9377
9382
SELECT to_timestamp(982384720.12);
9378
9383
<lineannotation>Result: </lineannotation><computeroutput>2001-02-17 04:38:40.12+00</computeroutput>
9379
9384
</screen>
9385
+
9386
+ <para>
9387
+ Beware that applying <function>to_timestamp</function> to an epoch
9388
+ extracted from a <type>date</type> or <type>timestamp</type> value
9389
+ could produce a misleading result: the result will effectively
9390
+ assume that the original value had been given in UTC, which might
9391
+ not be the case.
9392
+ </para>
9380
9393
</listitem>
9381
9394
</varlistentry>
9382
9395
0 commit comments