RE: Any way to change timezone WITHOUT mysqld restart?

2010-10-04 Thread Daevid Vincent
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
<http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar
_time_zone> time_zone variable. Initially, the session variable takes its
value from the global
<http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar
_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
<http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#functi
on_now> NOW() or
<http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#functi
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:
http://dev.mysql.com/doc/refman/5.1/en/mysql-tzinfo-to-sql.html

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
whacky discrepencies.

http://php.net/manual/en/function.date-default-timezone-set.php

There's plenty of info on this out there for using PHP & MySQL if that's
what you're using too...

http://www.ferdychristant.com/blog//archive/DOMM-84NEJN

 

  _  

From: Bryan Cantwell [mailto:bcantw...@firescope.com] 
Sent: Saturday, October 02, 2010 5:18 AM
To: Daevid Vincent
Cc: mysql@lists.mysql.com
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
says. 

On Fri, 2010-10-01 at 15:42 -0700, Daevid Vincent wrote: 

Did you even look at the manual?



http://lmgtfy.com/?q=mysql+set+timezone



First link.

 



> -Original Message-

> From: Bryan Cantwell [mailto:bcantw...@firescope.com] 

> Sent: Friday, October 01, 2010 10:25 AM

> To: mysql@lists.mysql.com

> 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.

> 

> 

> 






Re: Any way to change timezone WITHOUT mysqld restart?

2010-10-03 Thread Johan De Meersman
I suggest you put your glasses on, then. Getting of that horse might help,
too.

default-time-zone='*timezone*'
>
>  If you have the 
> SUPERprivilege,
>  you can set the global server time zone value at runtime with
> this statement:
>



On Sat, Oct 2, 2010 at 2:18 PM, Bryan Cantwell wrote:

> 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 says.
>
> On Fri, 2010-10-01 at 15:42 -0700, Daevid Vincent wrote:
>
> > Did you even look at the manual?
> >
> > http://lmgtfy.com/?q=mysql+set+timezone
> >
> > First link.
> >
> >
> > > -Original Message-
> > > From: Bryan Cantwell [mailto:bcantw...@firescope.com]
> > > Sent: Friday, October 01, 2010 10:25 AM
> > > To: mysql@lists.mysql.com
> > > 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.
> > >
> > >
> > >
> >
>
>
>


-- 
Bier met grenadyn
Is als mosterd by den wyn
Sy die't drinkt, is eene kwezel
Hy die't drinkt, is ras een ezel


RE: Any way to change timezone WITHOUT mysqld restart?

2010-10-02 Thread Bryan Cantwell
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 says. 

On Fri, 2010-10-01 at 15:42 -0700, Daevid Vincent wrote:

> Did you even look at the manual?
> 
> http://lmgtfy.com/?q=mysql+set+timezone
> 
> First link.
>  
> 
> > -Original Message-
> > From: Bryan Cantwell [mailto:bcantw...@firescope.com] 
> > Sent: Friday, October 01, 2010 10:25 AM
> > To: mysql@lists.mysql.com
> > 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.
> > 
> > 
> > 
>