Re: Timezone

From: Lew Pitcher <lew.pitcher_at_digitalfreehold.ca>
Date: Tue, 06 Nov 2018 13:18:09 -0500
Message-ID: <prslt4$l4$1_at_dont-email.me>


Percival John Hackworth wrote:

> On 04-Nov-2018, bill wrote
> (in article <prn0dk$iom$1_at_gioia.aioe.org>):
>

>> My server is on the West Coast. My client is in the Eastern
>> timezone. Is there any way to have a default timezone set to the
>> Eastern timezone so that NOW() will return the client local time ?
>>
>> bill

>
> That's a function of the OS that's running your server.

Not precisely true. You've left a lot out.

  1. The MySQL client application can set it's own timezone prior to issueing any time-stamp related SQL. If so set, this timezone setting takes precedence over the MySQL server timezone, and timestamp-related fields (including NOW() ) will reflect the timezone selected by the MySQL client. If not set, then the values of those timestamp fields will reflect the the timezone selected by the MySQL server.
  2. The MySQL server can select it's own timezone on startup. If so set, this timezone setting takes precedence over the OS timezone and timestamprelated fields (including NOW() ) will reflect the timezone selected by the server. If not set, then the values of those timestamp fields will reflect the the timezone selected by the operating system.
  3. The operating system may be able specify that applications run with a distinct timezone, seperate from the OS operations timezone. If so set, then the application (in this case, the MySQL server) will see a "system"-level timezone that is different from the OS's operations timezone. If not set, then the application will see a "system"-level timezone that is identical to the OS operations timezone.
  4. The operating system may present date/time values based on an "operations" timezone, and not as the system clock would present them.

So, the OS UI can present under a different timezone than the OS runs. (i.e. OS UI presents timestamps in CST, but OS runs in UTC.)

And, the MySQL server can run under a different timezone than the OS UI presents. (i.e. MySql server runs in MST, but OS UI runs CST, and OS runs UTC) And, the MySQL server can present timestamps under a different timezone than the MySQL server run in. (i.e. MySQL server defaults timestamp presentation to Atlantic time, while MySql server runs in MST, OS UI runs CST, and OS runs UTC.)

And, the MySQL client can present timestamps under a different timezone than the MySQL server presents in. (i.e. MySQL cilent presents timestamps in EST while MySQL server defaults timestamp presentation to Atlantic time, MySql server runs in MST, OS UI runs CST, and OS runs UTC.)

> Google for setting
> the timezone for your server. Then login as admin or root and do it.

There are so many other ways to solve this problem. Especially if you realize that the OP represents the Client and has no control over the server.

HTH

-- 
Lew Pitcher
"In Skills, We Trust"
Received on Tue Nov 06 2018 - 19:18:09 CET

Original text of this message