Jump to content

Has anyone used the function Convert_tz()?


kee2ka4

Recommended Posts

I am thinking of using the CONVERT_TZ(dt,from_tz,to_tz) function of MySql that converts the from-timezone 'from_tz' into the to-timezone 'to_tz', basically I want the convert the hosting companys timezone into the london timezone, so that the NOW() function displays correct value.

 

Could anyone tell me how can I find out the hosting company's timezone or is there any default timezone I can use. I just want the clerify the values I enter in the variable 'from_tz' and 'to_tz'. I think the values for to_tz is Europe/London or GB, but not sure!

 

Thanks,

Ket

Link to comment
Share on other sites

Hey Fenway,

 

Thanks for your message

 

If you set the client timezone differently from the server timezone, mysql will do this for you.

I am not sure how to do the above in MySql

 

I have a query that pulls the post.created_at field and formats the day, month and time, using the date_format() function. Here is the query:

$query = "select posts.id as id, posts.body, date_format(posts.created_at, '%d') as formatday, date_format(posts.created_at, '%b') as formatmonth, date_format(posts.created_at, '%H:%i') as formattime, posts.user_id, users.name 
              from posts, users
	      where 
	      posts.user_id = users.id
	      order
	      by posts.id desc"; 

How do I convert the time to the UK time since the Timezone on the hosting server is CDT, and I need the GMT to display the correct london time. If you think Convert_tz() is the correct function to use, how can I use it in the above query.

 

Thanks,

Ket

 

Link to comment
Share on other sites

Hey Fenway, Thanks for your reply.. I did read the article but I didn't quite understand it, I guess I am just dumb  :-[. I didn't get the bit on how can I set the session timezone and the global timezone.

 

Since I use PhpMyAdmin to manage my whole database, I do not know anything abt using the mysql command prompt as shown in the article. I did try using the convert_tz() as mentioned in the end but it didnt work. Actually I am lost lolz. Could you guide me?  ???

 

Thanks,

Ket

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.