Requesting clarifying details on extract(epoch from timestamp)

From: ralph(dot)holz(at)gmail(dot)com
To: pgsql-docs(at)postgresql(dot)org
Subject: Requesting clarifying details on extract(epoch from timestamp)
Date: 2017-08-18 06:05:06
Message-ID: 20170818060506.27369.84309@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/9.6/static/functions-datetime.html
Description:

Hi everyone,

I would like to request a clarifying statement in the docs:

https://www.postgresql.org/account/comments/new/9.6/functions-datetime.html/

Specifically, for the case of 'extract epoch', the docs state:

"for date and timestamp values, the number of seconds since 1970-01-01
00:00:00 local time"

I ran an experiment, importing a timestamp '2016-06-26 20:01:38' with
default time zone 'localtime', which is AEST in my case.

SELECT id, extract(epoch FROM not_before) FROM bla;
-> 1466971298

Now I switch to timezone = 'UTC' in postgresql.conf. Confirming with SHOW
TIMEZONE that I am now in the default UTC timezone in my session. Same
query:
-> 1466971298

In other words, it seems that the function extract(epoch from timestamp)
considered the timestamp field to be in UTC in both cases. I find it hard to
reconcile that with the docs.

Am I misreading something or is that something that should be fixed in the
docs?

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Michael Paquier 2017-08-18 07:28:21 Re: Default names for CRL and CA files in the backend
Previous Message Erwin Brandstetter 2017-08-18 00:01:39 to_char(): 'FM' also suppresses *trailing* zeroes