sql - Can MySQL convert a stored UTC time to local timezone? -


Can MySQL convert a stored UTC time into a local timezone: Ed time directly in a general selection statement?

Suppose you have some data with Timestamp (UTC).

  create table 'some data tab' (`id`in (11) null auto_interpretation,` value float tap default '0', 'date', '0000-00-00 00:00:00 ', Primary Key (`ID`) by default is not zero time zero  

Then when I select

 " value, some dates Date from ";  

I definitely get all the dates in their stored UTC form.

But we say that I want to do them with other timezones (DST), can I add some magic to selected queries so that I get all the dates in the chosen time zone?

  Select "value" from the charetate, the timezone (date, "Europe / Berlin");  

Or let me head it in some other layer

Thanks Johan


If your MySQL installation is done If you allow to use CONVERT_TZ, this is a very clear solution, this example shows how to use it.

  SELECT CONVERT_TZ ('2010-01-01 12:00', 'UTC', 'Europe / Stockholm')  

However I do not know that this is a good way because some MySQL installs this function Use it carefully.

Yes, convert_ts function.

< P>


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -