Trust me, I read it.
We had an I18N product at my last company and all our time was stored in
UTC in mySQL and we'd alter it on the fly for each user. This isn't rocket
science. It's done every day in probably many of the sites you visit and
don't even know it.
To clarify for you (again):
Per-connection time zones. Each client that connects has its own time zone
setting, given by the session
_time_zone> time_zone variable. Initially, the session variable takes its
value from the global
_time_zone> time_zone variable, but the client can change its own time zone
with this statement:
mysql> SET time_zone = timezone;
The current session time zone setting affects display and storage of time
values that are zone-sensitive. This includes the values displayed by
functions such as
on_now> NOW() or
on_curtime> CURTIME(), and values stored in and retrieved from
<http://dev.mysql.com/doc/refman/5.1/en/datetime.html> TIMESTAMP columns.
Values for <http://dev.mysql.com/doc/refman/5.1/en/datetime.html>
TIMESTAMP columns are converted from the current time zone to UTC for
storage, and from UTC to the current time zone for retrieval.
Don't forget to do this stuff too:
So if it's not clear by now, you store all your dates/times in UTC (convert
them via some script if you didn't start out that way). Then per web page
connection, you read the user's profile TZ (presumably from the user
session object or some other persistent means), execute that SQL statement
above as one of the first things on the page, and "FM" ensues. All your
properly saved mysql rows will display in the LOCAL "timezone" instead of
UTC. You ALSO have to set the TZ in PHP too don't forget or you'll get
There's plenty of info on this out there for using PHP & MySQL if that's
what you're using too...
From: Bryan Cantwell [mailto:bcantwell@stripped]
Sent: Saturday, October 02, 2010 5:18 AM
To: Daevid Vincent
Subject: RE: Any way to change timezone WITHOUT mysqld restart?
As a matter of fact I did, the real question is : Did you even read my
email? I said WITHOUT a restart...
The manual states that a restart of the mysqld is required. The reason for
the post to such a list is because on many occasions, user have suggestions
on some workaround for things that do work in spite of what the manual
On Fri, 2010-10-01 at 15:42 -0700, Daevid Vincent wrote:
Did you even look at the manual?
> -----Original Message-----
> From: Bryan Cantwell [mailto:bcantwell@stripped]
> Sent: Friday, October 01, 2010 10:25 AM
> To: mysql@stripped
> Subject: Any way to change timezone WITHOUT mysqld restart?
> Any way to change timezone WITHOUT mysqld restart?
> It would be a lifesaver if there were some way for me not to have to
> restart because if mysql restarts then I have to go through a lot of
> other issues with my other apps.