Re: Indicated Epoch 0 is incorrect

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: ian(at)thepathcentral(dot)com
Cc: pgsql-docs(at)postgresql(dot)org
Subject: Re: Indicated Epoch 0 is incorrect
Date: 2016-06-07 15:14:04
Message-ID: CAEfWYyzs6sVF1ftryEwNfwpx7pzsjYv=7=dPXDUkQxx22uXDqA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

The docs are correct. When you convert a string to a timestamp with time
zone it will interpret the string in *your* time zone which is apparently
offset from UTC.

Try:
select extract(epoch from timestamp with time zone '1970-01-01
00:00:00-00');
or
select extract(epoch from timestamp with time zone '1970-01-01 00:00:00
UTC');

Note the explicit definition of timezone offset of zero or time zone of UTC.

Cheers,
Steve

On Fri, Jun 3, 2016 at 4:44 PM, <ian(at)thepathcentral(dot)com> wrote:

> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/9.1/static/functions-datetime.html
> Description:
>
> Per /docs/current/static/functions-datetime.html (and earlier), epoch is
> defined as:
>
> &quot;For date and timestamp values, the number of seconds since 1970-01-01
> 00:00:00 UTC&quot;.
>
> The correct value to obtain 0 is as follows:
>
> SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE &#39;1970-01-01
> 8:00:00.0&#39;)
>
> --
> Sent via pgsql-docs mailing list (pgsql-docs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-docs
>

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Tom Lane 2016-06-07 20:11:13 Re: Math function description issue
Previous Message Simon Riggs 2016-06-07 14:46:17 Copy editing of Dynamic Shared Memory code comments