Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--use_client_time_zone does not affect all date-related functionality #699

Closed
George3d6 opened this issue Apr 14, 2017 · 4 comments
Closed
Labels
comp-datetime date & time & timezone related

Comments

@George3d6
Copy link
Contributor

After starting the client with said flag = 1 I got the following:

┌─toDateTime(1492124400)─┐
│ 2017-04-13 23:00:00 │
└────────────────────────┘

┌─toDate(1492124400)─┐
│ 2017-04-14 │
└────────────────────┘

This behavior seems rather unpredictable, is this to be expected or is this a bug ?

@ztlpn
Copy link
Contributor

ztlpn commented Apr 15, 2017

Yes, this is a bug/limitation of how timezones currently work. The problem is that the client cannot set the server-side session timezone. All it can change is the timezone of client-side operations (that is, parsing and formatting).

Here is a good mental model to help you avoid such surprises:

  • There are two timezones, server-side and client-side. Most of the time they are equal, but you can change client timezone with --use_client_time_zone
  • Client-server protocol uses Unix timestamps to exchange DateTime values and days since epoch to exchange Date values. These are considered timezone-independent.
  • All operations except parsing and formatting are handled by the server.

So in your case toDate() value is calculated by the server using the server timezone and sent to the client. The value is then formatted by the client (and Date values are formatted without regard for timezone).

@alexey-milovidov
Copy link
Member

alexey-milovidov commented Apr 17, 2017

You always could specify time zone explicitly, for example:

toDate(1492124400, 'America/New_York')
2017-04-13

@stiv-yakovenko
Copy link

Please add jdbc connection property, because this problem provokes writing guly code...

@den-crane
Copy link
Contributor

den-crane commented Sep 18, 2018

Please add jdbc connection property, because this problem provokes writing guly code...

jdbc has these properties
ClickHouse/clickhouse-java#202

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-datetime date & time & timezone related
Projects
None yet
Development

No branches or pull requests

6 participants