title: mysql getting epoch time
body: <p>I am using a table with:</p>
  
  <pre><code>CREATE TABLE tv (
      datetime datetime NOT NULL,
      value int(4),
      metric varchar(25),
      PRIMARY KEY (datetime)
  );
  </code></pre>
  
  <p>My system is in CET so I get this from a select:</p>
  
  <pre><code>select * from tv;
  +---------------------+-------+----------+
  | datetime            | value | metric   |
  +---------------------+-------+----------+
  | 2017-08-09 14:17:27 |     0 | TV power |
  | 2017-08-09 14:20:04 |     0 | TV power |
  | 2017-08-09 14:40:04 |     0 | TV power |
  | 2017-08-09 14:45:03 |     0 | TV power |
  </code></pre>
  
  <p>When I try to graph it (in grafana), I use:</p>
  
  <pre><code>SELECT
    UNIX_TIMESTAMP(datetime) as time_sec,
    value,
    metric
  FROM tv
  ORDER BY datetime
  </code></pre>
  
  <p>And it works fine except that it writes everything with 2 hours more in the future. So I guess this is because the UNIX_TIMESTAMP is thinking that the datetime is in UTC and looking at the system value, as it is CET, it is doing a +02:00 before converting to epoch or something like this.</p>
  
  <p>I get this also:</p>
  
  <pre><code>SELECT @@global.time_zone;
  +--------------------+
  | @@global.time_zone |
  +--------------------+
  | SYSTEM             |
  +--------------------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <p>Meaning it is using the system timezone which is CET.</p>
  
  <p>How can I get my UNIX_TIMESTAMP to convert correctly to the CET?</p>
  
  <p>Thanks.</p>