MySQL Forums
Forum List  »  General

How do I change Mysql timezone ?
Posted by: Celia Rexselin
Date: October 25, 2004 11:49PM

Hi all,
I 've got a database in which the timestamp is stored as
the number of seconds elapsed from 1970-01-01 00:00:00 GMT


a sample data would look like

TABLE
--------------
slot
0 --> 1970-01-01 00:00:00
3600 --> 1970-01-01 01:00:00
7200 --> 1970-01-01 02:00:00
10800 --> 1970-01-01 03:00:00
14400 --> 1970-01-01 04:00:00


(Note : the right part is not stored in the database .. I have added it
so that we know what datetime a slot should return at any point).

And now I have a form through which I get a datetime from the user and then
return the corresponding slot to him/her.For this , I use a unix_timestamp()
function that will convert a datetime to seconds and get the required result.

But when I query mysql with this command in a windows machine (mysql version 4.0.18)

SELECT unix_timestamp( '1970-01-01 04:00:00' )
I get "0" as result.

where as in a Linux machine (mysql version 3.23.54)
I get "-5400"


Then I found out that my mysql system variable "timezone" follows "India
Standard Time"... Now how do I determine my CURRENT SERVER TIMEZONE and
change my unix_timestamp function so that it always returns the correct slot to me?

Thanks in advance.
Regards,
Celia

Options: ReplyQuote


Subject
Written By
Posted
How do I change Mysql timezone ?
October 25, 2004 11:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.