title: Can MySQL convert a stored UTC time to local timezone?
body: <p>Can MySQL convert a stored UTC time to local time-zoned time directly in a normal select statement?</p>
  <p>Let's say you have some data with a timestamp (UTC).</p>
  <pre><code>CREATE TABLE `SomeDateTable` (
    `id`    int(11) NOT NULL auto_increment,
    `value` float NOT NULL default '0',
    `date`  datetime NOT NULL default '0000-00-00 00:00:00',
    PRIMARY KEY  (`id`)
  )
  </code></pre>
  <p>Then when I</p>
  <pre><code>&quot;select value, date from SomeDateTable&quot;;
  </code></pre>
  <p>I of course get all the dates as in their stored UTC form.</p>
  <p>But let's say that I would like to have them in another timezone (with DST),
  can I then add some magic to the select query so that I get all the dates back in the selected timezone?</p>
  <pre><code>&quot;select value, TIMEZONE(date, &quot;Europe/Berlin&quot;) from SomeDateTable&quot;;
  </code></pre>
  <p>Or must I do this in some other layer on top, like in some php code?
  (it seems to be how most people have solved this problem).</p>
  <hr />
  <p>If your MySQL installation allows you to use CONVERT_TZ it is a very clean solution,
  this example shows how to use it.</p>
  <pre><code>SELECT CONVERT_TZ( '2010-01-01 12:00', 'UTC', 'Europe/Stockholm' )
  </code></pre>
  <p>However I don't know if this is a good way since some MySQL installation is missing this function, use with care.</p>