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