Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...