Changing the connection timezone in MySQL

前端 未结 6 753
情话喂你
情话喂你 2020-12-28 14:07

My server is running in MDT

So I used following one to convert EST

SET  time_zone = \'-5:00\'

But, how c

6条回答
  •  误落风尘
    2020-12-28 14:40

    Have you tried using a zoneinfo name such as "America/New_York" instead of the abbreviation (which is only valid for half the time)?

    Ideally, you shouldn't use the server time zone at all of course - store dates in UTC and then convert it to the appropriate time zone in the client code. (This does depend on what you're storing, mind you. Future date/time values specified by a user with a time zone should be stored that way, not converted to any other time zone, in case the rules change between now and the future date/time. But for instants in time recorded by machines, e.g. for logging, transactions etc, I'd definitely store UTC. I would never suggest storing "just the local time and assume that the server and the client have the same rules".)

提交回复
热议问题