Jump to content

MySQL timezone


Petzet

Recommended Posts

Hi!

 

Do you know how to change MySQL's time zone to GMT, so that all the functions relative to date and time work according this time zone?

 

To store date and time in my DB I use TIMESTAMP fields, with the Default "CURRENT_TIMESTAMP", because it's the most convenient way.

But I found that MySQL's time zone is set to Los Angeles and I am in GMT, so all the TIMESTAMPs get wrong to me.

 

Thankyou!

Petzet

Link to comment
Share on other sites

Well, I think if you were to do that, it would change the timezone for everyone on the server.

 

California is on GMT-8, so you could just add 8 hours to the value of Current_Time (which if I understand correctly, is the same as NOW().)

 

I think you're looking for the function CONVERT_TZ(time-date, starting_timezone, new_timezone).

 

EDIT: In this case, I think for the current timezone, you would use PST.

Link to comment
Share on other sites

Yes, but I already have the timestamps written in California's time zone.

 

I should use that function while SELECTing, right?

 

I use PHP. What if I have the following:

SELECT * FROM users;

 

How do I use that function there?

I want the date field (TIMESTAMP) to be SELECTed with my timezone, right?

 

Sorry if I didn't understand...

 

Thankyou for your help.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...