RE: Retrieve the server's time zone

From: Marc Mamin <M(dot)Mamin(at)intershop(dot)de>
To: Dave Cramer <pg(at)fastcrypt(dot)com>, Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: List <pgsql-jdbc(at)postgresql(dot)org>
Subject: RE: Retrieve the server's time zone
Date: 2017-11-21 11:48:29
Message-ID: B6F6FD62F2624C4C9916AC0175D56D88594B1541@jenmbs01.ad.intershop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


>
> From: davecramer(at)gmail(dot)com [mailto:davecramer(at)gmail(dot)com] On Behalf Of Dave Cramer
> Sent: Dienstag, 21. November 2017 12:30
> To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
> Cc: List <pgsql-jdbc(at)postgresql(dot)org>
> Subject: Re: Retrieve the server's time zone
>
> It is in the session startup messages. I'm trying to recall the technical details as to why. My recollection is that for timestamps without timezone will be reported in the client timezone.
>
> Do you want the server timezone or postgres timezone. A simple C function should provide the latter.

Hello,
As a workaround, you could add your own GUC variable "myServerTimeZone"
regards,
Marc Mamin

>
> Dave Cramer
>
> davec(at)postgresintl(dot)com
> www.postgresintl.com
>
>> On 21 November 2017 at 02:01, Thomas Kellerer <spam_eater(at)gmx(dot)net> wrote:
>> Hello,
>>
>> it seems the JDBC driver (or Java?) makes it impossible to retrieve the server's time zone.
>>
>> Apparently the driver changes the timezone setting so that it can't be reset to the original from the server.
>>
>> When I run "show timezone" from within JDBC I *always* get the client's time zone, even if I do a "reset timezone" before that
>>
>> When I do the same with psql I can see the server's time zone.
>>
>> Ultimately I would like to get the server's time, e.g. by running something like:
>>
>> select current_timestamp at time zone server_timezone
>>
>> I already posted this to the general mailing list, because I initially thought this was a Postgres problem.
>> Tom Lane suggested, I could see the original time zone the server is set up with using:
>>
>> select reset_val from pg_settings where name = 'TimeZone';
>>
>> But that again returns the client's time zone through JDBC, but the real time zone through psql.
>>
>> It seems the driver changes this setting permanently for the session.
>> If that is the case, can I prevent that somehow?
>>
>> Thomas
>>
>
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Vladimir Sitnikov 2017-11-21 11:52:45 Re: Retrieve the server's time zone
Previous Message Álvaro Hernández Tortosa 2017-11-21 11:42:30 [pgjdbc/pgjdbc] befea1: Add SCRAM-SHA-256 support (#842)